I’m new to design patterns, I have a use case where I need to create the same objects over and over. In my case, I’m parsing a large XML file, and I need to create one object of each chunk. All the object have the same methods, except for the value stored are different.
Currently, I’m doing this in a procedural way: create a reader of the XML file, a static method parseEntry takes chunks of , and parse them into a POJO.
I figure there’s gotta be a better way of doing this.
Thanks,
I’m new to design patterns, I have a use case where I need to
Share
Create a Factory class using the Factory Pattern that generated the objects for you.
Another approach would be to use the Composite pattern, this pattern is very useful in game programming where using Inheritance can overcomplicate the architecture of the game and make objects tightly coupled to each-other.