On my way to better understand object-oriented programming (t d) and thereby check “Learn enough Objective-C to be dangerous” off my ThingsToDo list, I picked up The Object-Oriented Thought Process by Matt Weisfeld.
Not having formal training in software engineering, I found the book’s focus on the language-agnostic basics of OO extremely helpful.
Here’s what I learned from the book:
- Classes are almost always nouns
- A Class’s ‘Responsibilities’ are almost always verbs
- In the Model-View-Controller (MVC) pattern;
- Model = the application object, the data-model
- View = the screen presentation
- Controller = the user interface’s response to user input
- (this wasn’t as helpful as I’d like, it may just need to sink in)
- ‘is-a’ relationship = one object is a specific version of a more general object (e.g. Hamlin is a turtle)
- ‘has-a’ relationship = one object has another object contained within it (e.g. a bicycle has a seat)
- Patterns are general principles for solving programming problems
- AntiPatterns are specific examples of programming problems solved poorly or solutions to redeem poorly-solved problems
Weisfeld was mostly language-agnostic, he uses Java (t d) for his examples. At times, the example code gets in the way of the illustrating the point. With the little I know about Ruby (t d) (100% object-oriented, simpler syntax than Java), I may have chosen that language to illustrate OO principles to novices.
If you’re looking for a non-programming book to wrap your head around OO, I haven’t found an alternative to The Object-Oriented Thought Process.
One alternative would be Taylor’s _Object Technology_ [amazon]. Not saying it’s better or worse, just an alternative.
Also, in your example, while Hamlin is indeed a turtle, Hamlin is also an *instance* of turtle, which isn’t necessarily what OO design means when it talks of an ‘is-a’ relationship. A better example might be that Hamlin is some sort of special ClimbingTurtle and that a ClimbingTurtle ‘is a’ Turtle because ClimbingTurtle extends Turtle.
Also of note: ClimbingTurtles rule.