munificent/game-programming-patterns

Subclass sandbox two-stage initialization

FelixWeinreich opened this issue · 0 comments

To avoid having to create constructors on each subclass with all parameters needed for the base class initialization, we switched to two-stage initialization. However, directly afterwards, we come up with the createSkyLaunch to wrap both initialization stages in one function. The way we do that, we would need seperate functions for each subclass, each taking all parameters needed for the base class, which means we are back to our initial problem (correct me if I'm wrong here).

Could we apply one of the concepts from the prototype chapter and e.g. make it a template function? (Which btw. only works if the constructors of all subclasses take the same parameters?)