mardi 8 octobre 2019

What is the purpose of the "Breed" example in these "Type Object design pattern" explanations?

These are the two of the best explanations of "Type Object" design pattern that I could find, and I couldn't find many;

I totally get the concept of avoiding making a class file for every new type, by making a generic "Unit" class (as in the case of a strategy game) where the Unit class contains all the different variables that a unit can have, and instead loading that data from a file depending on what type of unit it needs to be. This means making new units means just making new data files outside the code, and no recompiling, and the task can be handed off to a designer.

What I don't get is the explanation of having a "Breed" class - both explanations do a poor job of explaining how it solves the initial problem; it seems like it's just moving the problem to the Breed class. Even though I know that can't be what they're saying.

Aucun commentaire:

Enregistrer un commentaire