News for hackers. Stuff that matters.
Re:Ask HN: Best example for teaching the basics of object or... by Revell on Monday August 24, 2015 @02:46AM (#10108267)
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?
Re:Ask HN: Best example for teaching the basics of object or... by auxym on Monday August 24, 2015 @08:22PM (#10113651)
That's a good point. As a second suggestion, I think I liked Dive Into Python's example of a mp3-file metadata parser, from way back when I learned python

http://www.diveintopython.net/object_oriented_framework/inde...

Re:Ask HN: Best example for teaching the basics of object or... by atmosx on Sunday August 23, 2015 @04:42PM (#10106681)
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

Re:Ask HN: Best example for teaching the basics of object or... by ghrifter on Sunday August 23, 2015 @08:49PM (#10107356)
How about a pen?

A pen is tangible and has properties.

    pen.brand = 'bic';
    pen.inkColor = 'black';
etc