Abstract factory

The abstract factory pattern is closely related to the factory method pattern. Sometimes, the problem requires the creation of multiple distinct objects that are somehow related. In such a case, we could introduce multiple factory methods, but then we have to manage them separately, which increases the possibility of implementations becoming out of sync. This approach also makes it hard to share common logic and state between those factory methods. A better way is to introduce an abstract factory, which functions as a factory for factories.

If a factory method is a kid with a cookie cutter, an abstract factory is a kitchen chef. Give them a set of cooking tools and they'll make you a great dish. Give them access to a baking ...

Get Hands-On Design Patterns with Delphi now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.