I am new in the world of Java, so apologies my ignorance.
I've developped a c++ code for scientific visualization (with opengl). My goal would be to convert this soft from C++ to java, because I am tired to maintain it on 3 different operating systems (Windows, Linux and MacOS). However, before trying to convert such a complex program, I would like to make sure it can be converted with no dommages for the current users.
The heart of the code is the reading of a (custom) binary file containing all the objects to be displayed in a very compact format (that I don't want to describe here). But the main thing is that while reading this binary file, I am creating objects from different class (depending on the first byfe of the chunks of data that I am reading), all these objects inherits from a common base class.
In order to initialize the objects using the "right" class, is to do a switch of the first byte and depending on the value of that byte, I initialize my object using the constructor of the right class.
What I would like to know is:
1) can I use a similar strategy in java?
2) is there a better strategy that I could use ?
--> typically I would like to have a code that find itself which constructor/object to use. That would avoid me to systematically have to add a new entry inside my "switch". At the end, I'd like to have these class as pluggins and to allow the users to define a new type of object (a new class) without having to change any part of the software code except for their simple pluggin.
Any suggestion for a way to do this properly?
Thanks in advance for your help,