views:

337

answers:

7

Hi I have been given an opportunity to teach C++ Programming to school students, who are beginners to programming. I have introduced them programming basics neatly and now it is time for me to move on to teach them OOP Concepts. I can teach them about classes and objects but i have no creative ideas to introduce them these concepts properly. Do any of you have any ideas of links/articles or tips by which I can help them to grasp the concept properly.

Due to the nature of the question I'm marking it as a wiki. Thanks

I'm in India, and here they are now 17 years old and it is their first time for programming. The schools have C++ programming in the syllabus. They are now in their 11th and 12th grades. I took up teaching programming because I thought I could help them and I like teaching. I prefer to teach from the analogy way where we can relate them to real life things and make them think to program.

A: 

You might start by dropping the OOPS thing - the term is OOP - Object Oriented Programming.

And teaching C++ to beginner programmers is no small undertaking (I speak as an ex C++ instructor). Can I ask why you have chosen this particular route?

anon
This isn't really an answer. Would probably have been better as a comment.
musicfreak
I would agree that other languages would be more suitable for beginners, but learning C++ in depth is not really necessary. You can easily ignore more advanced concepts and focus on basics.Forget abstract methods and polymorphism, just teach them basic encapsulation and inheritance.
Josip
Sorry, polymorphism is the heart of OOP.
anon
@Neil Butterworth: That's true, but when you teach MD students about the human body, you probably don't start with the heart. :-)
balpha
@balpha It wouldn't be a bad place to start. Modern medicine probably dates from Harveys work on the circulatory system.
anon
+1  A: 

I would say avoid the "dog is a class..." type thing, because when I was introduced to this, It just confused me, more than it tough me anything.

kkaploon
+1  A: 

I would start by explaining them the relationship between real-world objects and objects in the programming language. That's basically why OO programming is so powerful.

So you could start by taking an arbitrary object (from the real world) like a Person. Then let them guess what kind of properties/attributes a person has, i.e. a name (which can be divided in first/surname) etc... Then explain them that the objects behave the same way. They exactly represent the objects in the real world, also having properties for each property of the real-world object etc...

Juri
Did that analogy actually help you when you were just starting OOP?
kkaploon
kkaploon: I think the analogies are a great way teach OOP. Especially to someone who hasn't had lot of programming experience. It might be different case to teach OOP to someone who has hacked C for five years.
Kuytu
@kkaploon: Well this is a 1st approach. It may hold for novices in programming but also for procedural style programmers. How would you explain them otherwise why they should move over to OO programming??
Juri
Different people think differently. Personally, I've never found the analogies useful, but someone else might find them incredibly helpful.
musicfreak
They are almost always destructive, as computer programs (with the possible exception of Cyc) don't model the real world, but the processes that transform between abstractions of the real world.
Pete Kirkham
+11  A: 

I always find that the best "real world" use of object orientation (not in the "a dog is an animal with an additional bark() method" sense, but using a metaphor that makes sense) are GUIs.

A window is an instance of a (subclass of the) window class. It has properties like position, width, etc. It has methods like hide(), maximize(), etc. These are inherited from the base window class. It can also implement its own features, e.g. children objects, or an "always on top" property, etc.

The window is then an actual "real world object" (you can see it on the screen, move it, interact with it, etc). But it is also an object in the OOP sense.

By starting with a boilerplate window implementation and then slowly adding additional features to it, I think the idea of object orientation should be transportable in a natural (while still programming!) way. Using a framework that abstracts away some of the details of the Windows API (or whatever you're using), at least at first, might make it easier to start. I could suggest Qt, for example.

balpha
A: 

Teaching children is always a challenging task.
It would be worthwhile focusing on languages designed especially for teaching.
Start with a language suitable for the age group.
Smalltalk for example, was designed to teach such concepts.

nik
+2  A: 

Well, for one thing I'd say that teaching C++ to newbie programmers is not a very good idea. The language is quite complex and will be very difficult to beginners. I'd use Pascal instead - that was even created for the purpose of teaching. And it has objects too, so you can teach OOP as well.

As for teaching "what" an object is - well, tell them that it's a bunch of variables and functions bundled together in a single variable. Tell them about private variables. And then shower them with examples where objects can be used. Give them lots of excercises that have very obvious uses of objects. Make them identify the proper ways of encapsulating data in objects. Etc. Teach by examples.

One important thing is to tell them the difference between a "class" and an "object" early. Tell them that a "class" is a "blueprint" of an "object". It's not an object itself, but you can create objects based on it. Later also be consistent about these terms. Otherwise this can lead to a lot of confusion.

DISCLAIMER: I'm no teacher and, in fact, most my attempts of teaching other people have failed pretty miserably. But this is what would have worked for me (I think...)

Vilx-
If you use people as a basis of your teaching that might work quite well:Person: Class (blueprint for a human)Student: inherited personThomas: Object of type PersonPeople: Collection of type person
Mauro
Mary: inherited from Thomas. Got rich that way. :D
Vilx-
A: 

I wouldn't bring in any OO concepts at all. I'd give them a real world problem that's not too easy and walk them through solving it using OO tools. You can even go as far as making the first one or two sessions unrelated to a programming language. Just focus on abstraction, encapsulation etc.

After that, fill in the blanks with the concrete implementation details so that they have a framework into which you can plug in more complex concepts.

Noufal Ibrahim