Do you understand what encapsulation means, but don’t know why in the world you would want to use it?
Do you see examples of inheritance in the frameworks and libraries, but have only just dabbled with inheritance in your own code?
If you answered yes to these questions, you want to begin to learn the patterns literature.
Object oriented programming gives you the tools, but doesn’t tell you how to effectively use them.
We all just rummage in the dark sometimes, but after a while, some techniques started showing up over and over. A few years back, a group of clever researchers decided to ask some of the best developers using OO languages what solutions they were coming up with. If a solution tended to appear over and over, the researchers wrote it down, gave it a name, and described when it would be good to use.
These recurring solutions are called “design patterns.”
The landmark book that opened up design patterns to the world is called”Design Patterns, Elements of Reusable Object Oriented Software” by Gamma,Helms, Johnson, and Vlissides (a.k.a. the Gang of Four).
This book is an excellent reference, but not an easy read. I do not recommend that you start there. I recommend, instead, that you start with a slim and readable volume called”Design Patterns Explained” by Shalloway and Trott
These are not code snippets per se, although many books illustrate their examples using bits of code, and I’ve seen at least one patterns book come with a CD illustrating samples of each pattern (Design patterns in C# byCooper). Design patterns are not libraries, either. They are techniques and solutions to the problem of learning and understanding Object Oriented programming.
Take a look at the Shalloway book. If you aren’t a better programmer after reading that book, I’ll eat my hat. (I read it in two days… it’s an easy read)
A list of useful books in the patterns space can be found here:
(this blog posting was copied from my prior blog. I find myself referring to it in the forums from time to time, so I wanted to keep it around.)