Ask HN: What are some good books for understanding OOP?
Hi,
I am a novice programmer, currently self-learning, would really like to understand Object Oriented Programming well. Can anyone suggest some books that are good at explaning OOP for beginners?
Thanks for the help in advance. The most important thing to realize is that "object-oriented programming" isn't a well defined term. If you don't know what it means and you pick up books about Smalltalk or CLOS, you won't really have a good grasp on the corporate C++/Java/C# environments you might be thrown into, and if you get a job interview that asks "explain OOP to me", they won't have any fucking idea what you're talking about, because by "OOP" they mean Java and by "OOP" you'll mean Smalltalk or CLOS. Likewise, if you pick up a Java book, it'll take you awhile to figure out what Smalltalkers, Lispers, and Rubyists are on about. Unfortunately, the C++/Java conception of OOP has had a much better sales team since the 90's or so, so you can get sucked into that universe and never find your way out again. So learn OOP from multiple perspectives. In situations like those, I feel like OOP is some of the most buzzword laden areas of CS. Things like "Cohesion", "Layering", "Polymorphism", "Abstraction", etc. They are all great concepts with a lot of important principles, but I drives me nuts how often I've heard them used excessively. I would put http://en.wikipedia.org/wiki/Liskov_substitution_principle at the top of the list of things to understand. Language features like polymorphism and encapsulation aren't exclusively OO but they're provided because they help your designs follow LSP. > So learn OOP from multiple perspectives. This is key. Even if you end up never using the less traditional OOP models, learning them will let you write better software in the conventional languages. I can say with certainty that my basis in Smalltalk and (albeit limited) knowledge of Lisp makes me a far better Java programmer. In my opinion, Eric Evans' Domain Driven Design is just about the only book that gets OO right. Martin Fowler's Refactoring is pretty good on the technical side of things. I would avoid design patterns like the plague (edit: other than the Kent Beck Smalltalk book, which lots of smart people like - this is the one recommended by duck in this thread), but others disagree. Don't take this as advice against learning what you want to learn, but I'd caution against the idea that "object-oriented programming" and "good programming" are the same thing (or even that they are correlated). OO in its various incarnations comes with a tremendous amount of baggage. It took me years to figure out I didn't need it, and that insight made me a much better programmer. I know you asked for a book, but as a fellow self taught person I remember this video being really valuable to me when trying to get my head around OOP. http://video.google.com/videoplay?docid=-2058469682761344178... It is an older video of Dan Ingalls of Smalltalk fame explaining objects. I clearly remember a large light bulb going off in my head as he walked through his analogy of a hospital described as an object. This certainly isn't comprehensive, but if you are stuck on the concept its helpful to hear someone talk it out. I think this document provides a good introduction for a beginner:
http://www.runningcode.com.au/Resources/Aitken-Framework4OO.... C2 is another resource worth checking out. C2 is the original "wiki". While its not always coherent and will structured, there are some real gold nuggets here:
http://c2.com/cgi/wiki?ObjectOrientedProgramming I would recommend you OOSC (Object oriented software construction) by Bertrand Meyer. A mammouth book. Its length, which could be a hindrance, is its best point: you'll have plenty of explanations for every concept. Since you say you are a novice, I'd recommend Head First Design Patterns: http://www.amazon.com/dp/0596007124 Do not jump in with the GoF Design Pattern book. :) I thought that book was very well done, in terms of getting its lessons into your head -- but the lessons gave poor advice on the subject. (I don't remember specifics, it's been years.) I'd suggest starting a little closer to the beginning: Head First C# [1st choice because the program exercises are far more interesting] or Head First Java [which is pretty dull] Learn Python the Hard Way would be my choice for learning old school style. http://learnpythonthehardway.org/index The Head First books are a great idea, but to me they force too much of their way to learning instead of just presenting the information. I'm sure that is helpful to some... but it just gives me a headache when I try to read through them. Object-Oriented Design Heuristics: http://amzn.to/hMfVA6 This is a fantastic book on OOP design principals and has lots of language-agnostic examples. I don't know of any books that sound exactly right for you, but here are a couple I like that are relevant. You might find them kind of advanced right now: * Chapter 3 of http://mitpress.mit.edu/sicp/ -- also chapters 1 and 2. * _Abstraction and Specification in Program Development_, on design by contract. There's a newer book by the same authors, _Program Development in Java_, but Norman Ramsey says it's not as good. (I've only read the older one.) By Liskov & Guttag. Focuses on abstract datatypes rather than OOP classic. Bertrand Meyer's _Object-Oriented Software Construction_ covers much of the same material, but not as well to my taste in the bits I dipped into. * Also, _Smalltalk-80: The Language and Its Implementation_ at http://wiki.squeak.org/squeak/64 -- this might be more basic than the above two. The ideas were old to me by the time I got to it, so I don't know how well it'd work for a novice. * I've seen _A Little Smalltalk_ recommended as an intro to OO and it looks plausible: http://www.littlesmalltalk.org/index.php?page=the-book -- I haven't read it myself. The Object-Oriented Thought Process ( http://www.amazon.com/Object-Oriented-Thought-Process-3rd/dp... ) isn't a perfect book, but it's not a bad one. It refers too much to other books, but combine that with a language text and you should get the concepts pretty well. * Smalltalk Objects And Design by Chamond Liu * The Art of the Metaobject Protocol by Gregor Kiczales Don't let the second one fool you. Although it is a Lisp book, it presents OOP design principles applicable to any language. As the Amazon review says: "The Art of the Meta-Object Protocol is useful for the advanced CLOS user as well as for anyone interested in object-oriented programming and language design." Do you really think AMOP is suitable for a novice? Check out "Smalltalk Best Practice Patterns":
http://www.amazon.com/dp/013476904X/ Lots of OO classes use it and Smalltalk is a great language to learn OO with (but even if you don't use it, the general information will be a big help). That's an excellent book, and relevant, but I wouldn't say it directly answers the question: it's more about coding-in-the-small than object orientation. (Those subjects can shade into each other, it's true.) I found the first chapter of Design Patterns to be the most enlightening description of OO programming I have found. I have an intense desire to contribute to the Chromium Project, however, I too am a programming novice. I know a bit of Java, but not much else. I understand that this is a monumental end goal given my current situation, but can anyone point me in the direction of the best tutorial books that money can buy? Good karma for anyone that responds :) you may want to check this out: http://www.aaronboodman.com/2010/10/wherein-i-help-you-get-g... It seems that your first step is to to find good C++ resources: http://stackoverflow.com/questions/155762/best-c-resource Hope this helps. Object Oriented Programming by Timothy Budd. Its the starting book that I got and is proving very helpful to me. I highly recommend Head First Java, which focuses on OOP using Java. The entire Head First series is very well written, and focuses on practical learning rather than reference or academia as a lot of the suggestions do. Thank you all for the suggestions. Its given me a lot of food for thought.