Ask HN: Best example for teaching the basics of object oriented programming

3 points by bpesquet ↗ HN
Hi all,

I'm in the process of writing yet another introductory course to programming for complete beginners.

I'm looking for a great example context for my OO chapter, beyond the ubiquitous Animal or Vehicle hierarchy.

Thanks in advance for all your great ideas!

4 comments

[ 4.5 ms ] story [ 18.1 ms ] thread
I'm not an expert on the topic, but this book[1] has an incredibly good and easy-to-understand introduction on the topic. It's ruby-based but the ideas apply to OO design in general.

[1] http://poodr.com

How about a pen?

A pen is tangible and has properties.

    pen.brand = 'bic';
    pen.inkColor = 'black';
etc
Why not use a real-world example of something you would write a class for? The best tutorials are the ones that teach you things you can actually use. I've never used an Animal or Vehicle class myself. A better example might be to write something like an Article class, and then build out to a very simple and minimal blog?