April 2017
Beginner to intermediate
394 pages
9h 16m
English
In Chapter 5, Decoupling Code via the Factory Method Pattern we learned how to use a Dynamic Factory to decouple our stages, components, and objects from higher level modules. We did this by placing the dependencies of each derived class into a separate builder class instead of a high-level module. Let's look at an example of creating a derived type stage builder:
//SplashStageBuilder.h-------------------- #include "M5StageBuilder.h" class SplashStageBuilder: public M5StageBuilder { public: virtual M5Stage* Build(void); }; //SplashStageBuilder.cpp-------------------- #include "SplashStageBuilder.h" #include "SplashStage.h" M5Stage* SplashStageBuilder::Build(void) { return new SplashStage(); ...Read now
Unlock full access