the factory pattern
I made myself understand the factory pattern when I was taking Software Design during my fall 2008 semester. That is, I understood enough to do well in the course. Looking back I never really understood it; more importantly I didn’t see it’s usefulness.
This week I received the best explanation from my manager at work. The best part was being able to see the real world implementation of the factory pattern. I think the key thing that I was missing was that the factory will return an object that implements an interface, so you can have any number of implementations of the interface that will all be valid objects. Add in some inversion of control and you have yourself an amazing dynamic system where you can drop in libraries at anytime (even runtime) and use them as though they were compiled with the system.