A lot of confusion comes down to some bad use of inheritance. Probably the most important OO concept is the Liskov Substitution Principal, viz that if you specify a superclass in a certain place, then any subclass should be a valid use there. The strategy pattern (or its hyperpituitary cousin, IoC) takes advantage of this to allow for run-time change of behaviors, e.g., being able to choose through configuration how to serialize a data structure so the same basic logic can output, say, a dataset as a table or a graph. That said, as OO architecture has matured over the last few decades, there has definitely been a tendency to favor composition over inheritance for code flexibility. I would recommend Head-First Design Patterns as another great book for being able to “get” object-oriented architecture.
Head First Design Patterns
Eric Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra
Head First Design Patterns
Eric Freeman, Elisabeth Robson, Bert Bates, Kathy Sierra
7 readers recommend it across 6 discussions
Reader recommendations
- Sapiens - The Lord of the Rings - Siddhartha - Chaos: Making a New Science - The Death Gate cycle books - Neuromancer - Head First Design Patterns - Valis - Dune - The name of the rose I'm sure there are more, but these are the ones off the top of my head.
Also recommended in this reply
Head First Design Patterns is awesome. I read a couple other Design Pattern books, but didn't really get it. I didn't want to buy a "Head First" book because it looked kind of silly, but this book has finally opened my eyes to what Design Patterns are about.
1. Head First Design Patterns - Didn't learn patterns in school. This book made a lot of difference in communication with more experienced programmers. 2. Pragmatic Programmer - A classic, learned many practical tips for day to day programming job. 3. Founders at Work - Motivated me to work on my side projects and be constantly learning.
Also recommended in this reply
If you want a good alternative to the GoF book try Head First Design Patterns. I findit much more approachable and much more enjoyable to read. http://www.amazon.com/Head-First-Design-Patterns-Freeman-ebo... (http://www.amazon.com/Head-First-Design-Patterns-Freeman-ebook/dp/B00AA36RZY)
It depends heavily on what stage of your career as a programmer you are. I strongly suggest most junior programmers I work with to read Effective Java and Head First Design Patterns. To me, it's a great combination to help you write code that's easy to understand and maintain.
Also recommended in this reply
* The Pragmatic Programmer (Read this once every 6 months until it's obvious) * Head first design patterns * Agile Web Development with Rails It's not obvious, but the rails book is a great introduction to test-driven development in general.
Also recommended in this reply