The Dynamic Factory
While the Static Factory is simple enough for our purpose, the Mach5 Engine uses a different approach. This approach combines the polymorphic solution of the classic Factory method with the selection capability of the Static Factory. This new approach uses a searchable collection of derived StageFactory classes.
Remember that problem with the classic Factory method is that the method represents only one class to instantiate. This allows our code to be flexible because we don't depend on a derived Stage class or a call to the new operator. However, we still needed a way to get specific derived StageFactory instances.
In the Mach5 Engine, the names are changed a little. There is only one StageFactory class, which contains ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access