When making a sandwich, bread is only our first and most basic ingredient; we obviously need some kind of filling. In programming terms, this could mean simply building another interface like
Bread but calling it
Filling and providing it with its own associated factory. Equally, we could create a global interface called
Ingredient and have both
Filling as examples of this. Either way, we would have to do a fair bit of re-coding elsewhere.
The design pattern paradigm offers the abstract factory pattern as perhaps the most adaptable solution to this dilemma. An abstract factory is simply a factory that creates other factories. The added layer of abstraction that this requires is amply paid off when we consider ...