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

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -