The patterns that we have studied in the previous chapters, Handle and ADT, describe how encapsulated custom C data types may be implemented and what the costs and consequences such implementations carry and inflict on the surrounding software landscape.
The focus of the above patterns is very narrow - one custom data type wrapped into the mechanics of hiding information which is subject to variance the most.
In this chapter we will take the material developed previously further by concerning ourselves with situations when, for all practical purposes, the number of custom C data types grows without upper bound.
The Factory pattern may be used to create variables of encapsulated custom C data types that have a multitude of similar but different implementations attached to a single interface. Factory allows such variables to be created without the explicit dependency on concrete underlying custom data types.
The Abstract Factory pattern may be used to create variables of encapsulated data types that belong to a family of types - a logical whole that has a certain common underlying idea or a unifying theme. Abstract Factory allows such variables to be created without the explicit dependency on concrete implementation data types.
The Builder pattern may be used to create variables of encapsulated data types that have common parts. Builder captures, centralizes and hides the mechanics of a uniform process used to assemble such parts into different wholes.
The Prototype pattern may be used to create new variables by cloning the existing ones.
Singleton is a restrictive pattern that may be used to create the one and the only instance of a variable of a given encapsulated data type.
\(\blacksquare\)