Sprint Planner Helper – Session 14
February 24, 2009
Ok – today I’ll start by creating a factory for the Product class. I have some issues with the factory pattern and here is my reasoning: Another class is the creator and must have access to the NEW method of the class to create it. Since that forces at least a protected-level on the constructor, it means that I cannot be sure that clients use the factory and not the constructor.
If I place the factory method on the class I am creating, I can ensure this. But then I am violating the Single Responsibility Principle. What to do, what to do…
For now, in TDD/XP fashion, I’ll implement the simplest solution: a static Create method on the class I am creating. I don’t have several different Product types, so it’s the same factory for all products, possibly with overloads.
Flame...

