java - Better ways to handle object creation? -
i'm working on game has lots of types of objects, of them extend gameobject class. every object has it's own constructor. main class has creategameobject() method accepts class<?> type , compares each 1 of objects classes in game. have because each type has different constructor.
my question:
is there better way handle creation? making more generic? game has lots of types , makes code huge because of comparisons.
i'm making game in java, android, using libgdx.¡
i think factory design pattern come in handy in case. :)
the whole point object creation happens in separate class, making easier maintain.
you can basic overview of design pattern here. enjoy!
Comments
Post a Comment