59 votes
Accepted

Learning fundamental differences between functional programming and Object Oriented Programming

There are beautiful answers to this question already here, and I will not try to reiterate any of the ground that has already been covered. However, something important that I have not seen here so ...
Ben I.'s user avatar
  • 32.9k
44 votes

Is it important to teach pointers in a first course using Java?

Learning about references is important, but I don't feel that learning about pointers is that important for beginning Java students. Certainly intermediate students will need to understand them. When ...
pojo-guy's user avatar
  • 998
44 votes
Accepted

Interesting Programming Exercises to Teach Inheritance?

I'm not as familiar with Python as I am with other languages, but I'm sure your students have played Minecraft. If you haven't, I suggest taking a few minutes to find some introductory "Lets Play" ...
Draco18s no longer trusts SE's user avatar
31 votes
Accepted

Explaining access levels and visibility in OOP

Here's an analogy that I've used for several years, and that students seem to understand. It doesn't focus on the rules, but why we have public and private and protected. "Most of you know that I ...
Stephen Gilbert's user avatar
31 votes
Accepted

Is it important to teach pointers in a first course using Java?

For a beginning course: no. I have helped clarify behavior for fellow students who got lost by an instructor who explained things in terms of pointers. I have programmed in C, and most of my current ...
CAD97's user avatar
  • 514
16 votes

Is it important to teach pointers in a first course using Java?

No Because of the way that you learn, you think of them as fundamental, to the way references work. They are not. References do not have to work this way. [I would still agree that pointers are ...
ctrl-alt-delor's user avatar
16 votes

Learning fundamental differences between functional programming and Object Oriented Programming

Here I will discuss Functional Programming (FP) and Object Oriented Programming (OOP) in a fairly pure form. Actual languages, however often make compromises to allow older forms as well as multi-...
Buffy's user avatar
  • 36k
16 votes

Interesting Programming Exercises to Teach Inheritance?

Too many examples that you find are (IMO) fatally flawed. The Animal->Dog is especially flawed, though widely used. The problem is that these sorts of examples almost require that the superclass has a ...
Buffy's user avatar
  • 36k
15 votes

What is a good analogy for the Object Oriented paradigm?

I've got to jump in here and talk about my experience having to help a former boss understand why the project he wanted to do wasn't possible in the time available. It came down to incompatible data ...
Draco18s no longer trusts SE's user avatar
14 votes

What thought process would lead one to invent object-oriented programming?

There are a number of different ideas that are all called OO. I'm going to focus on the Simula-style OO. Here's my fiction which I think isn't too far off from reality: As computers became more ...
JimmyJames's user avatar
14 votes

Parent class variable pointing to Child class

Just to add on to Bryan R's response, upcasting is typically automatic, as a side-effect of data structures or methods that store or utilize a parent type. There's not much point to the example in ...
Ben I.'s user avatar
  • 32.9k
13 votes

Explaining access levels and visibility in OOP

What my teachers used was the following example, which is pretty simple and most people understood. Your father orders a pizza. The delivery guy arrives and expects payment. The ...
shalah allier's user avatar
13 votes

Is it important to teach pointers in a first course using Java?

What is important is to teach students the difference between Java objects, and Java variables. There are thousands of questions on Stack Overflow asked by students and by junior developers who do ...
Solomon Slow's user avatar
11 votes

Explaining access levels and visibility in OOP

Ooh, this is one of my favorite lessons! I don't introduce package private and protected in the same lesson as private and public, because there are 3 principles that I want them to absorb that ...
Ben I.'s user avatar
  • 32.9k
11 votes

Is it important to teach pointers in a first course using Java?

A related (rhetorical) question: Should C students be taught the [machine language] idea of reusing a pointer as a CPU instruction if the value happens to line up? The speaker in a Functional ...
Wildcard's user avatar
  • 645
11 votes

What thought process would lead one to invent object-oriented programming?

Even though you mention fearing the complexity of looking at wrong turns in its development, I think it is still instructive to change the question from "What would lead to the invention of object-...
lfalin's user avatar
  • 446
10 votes

Interesting Programming Exercises to Teach Inheritance?

I've got one that might help, modified/simplified from an actual problem I had to solve at my current job. Imagine you're writing a Content Management system - this system will store four types of ...
Kevin's user avatar
  • 290
10 votes

How necessary is UML for a course in object programming patterns?

As a professional software developer, I would recommend minimizing the time spent teaching UML. Teach the patterns. If they learn some UML along the way, so much the better. But don't burden them. ...
Cort Ammon's user avatar
  • 1,031
10 votes

How necessary is UML for a course in object programming patterns?

You are teaching a course on design patterns, not on UML. You just happen to be using UML for the graphical notations. As UML is not the subject, don't spend too much time on it. Spend just enough ...
Bart van Ingen Schenau's user avatar
10 votes
Accepted

Object Oriented Software Engineering Project

Let me first make a suggestion. First, understand, yourself, what OO really means at a deep level. It is not, fundamentally, about inheritance, and when inheritance is employed it should be done so ...
Buffy's user avatar
  • 36k
9 votes

Is it important to teach pointers in a first course using Java?

As someone who learned to program with ruby, I think that the concept of how a reference to an object works under the hood is vital. Having the knowledge that "under the hood" my variables may be ...
thesecretmaster's user avatar
  • 4,795
9 votes

Learning fundamental differences between functional programming and Object Oriented Programming

FP and OOP are both tools in the box, none of them is better or worse. The same way you would not ask whether to use a hammer or a screwdriver to put in a nail, you should not ask whether to use FP or ...
TwoThe's user avatar
  • 290
9 votes

Learning fundamental differences between functional programming and Object Oriented Programming

I wouldn’t expect to find a comparison table because OOP and FP are not mutually exclusive concepts. OOP is about encapsulating data in objects behind interfaces and using inheritance to build ...
Robert Fisher's user avatar
9 votes

Learning fundamental differences between functional programming and Object Oriented Programming

There are already several good answers, but I'd like to add the following. Functional code is (at least in theory) more easily parallellized. This is important because we've about hit the limit of ...
David's user avatar
  • 221
8 votes

What is a good analogy for the Object Oriented paradigm?

A good analogy might use animals and their classification. Class: think felines. A feline will purr, go out only at night, eat meat, etc. One could think of the methods purr, goOut:time, eat:food, ...
xuq01's user avatar
  • 276
8 votes

Analogy for abstract classes

The rules for abstract classes are the same as for other classes, with a few minor differences: An abstract class may have methods that do not have a body An abstract class has to be sub-classed, at ...
Gypsy Spellweaver's user avatar
8 votes
Accepted

Explaining how an Interface is a contract

A few things jump out from the official Java documentation: As far as an example goes, the idea of a Remote as an interface works really well based on this explanation. Methods form the object's ...
Peter's user avatar
  • 9,082
8 votes

Explaining how an Interface is a contract

This answer draws on Java examples. I start the interface discussion with a mechanical SATA hard drive in my hand. I discuss the interface called SATA and its universality across devices. I expand ...
ThisClark's user avatar
  • 293
8 votes
Accepted

Justification for an objects-early approach to introductory programming

tl;dr: When you teach with the OO paradigm, you get to control the flow of ideas and the level of complexity at any moment. Here we examine the first course in computing, no matter the educational ...
Buffy's user avatar
  • 36k

Only top scored, non community-wiki answers of a minimum length are eligible