Re: class hierarchy design problem
"dgront" <dgront@chem.uw.edu.pl> wrote in message
news:1154549894.272998.284260@h48g2000cwc.googlegroups.com...
How do you currently determine what file format(s) the input is
encoded
Some of the files have headers. But most of them were created in the
past times, when mostly FORTRAN was used. Therefore each file must have
an extension. Otherwise a user must explicitly define a format through
an option flag. If the format is wrong (wrong extension or a user made
a mistake), an exception is thrown.
Okay, and presumably the information you need to construct one
particular model object is spread across multiple files.
So I'd have a main driver class which organizes a list of files, and
maps them with their file formats. It would have 1 method: the static void
main method.
I'd then have a class to represent all the semantic data for each file
format, and thus create objects representing the contents of the files.
They'd have getters and setters.
I'd then have a translator class which takes in all these file objects
and converts them to model objects. It would have 1 method, taking in a
collection of file objects, and returning a collection of model objects.
I'd then have another translator class which takes in all these model
objects, and translate them back to file objects. Also 1 method, in the
reverse direction. Actually, this could be the same class as the previous.
I'd let the file objects know how to write themselves to disk. Each one
has 1 method.
That's 1 + N + 1 + M + 1 classes, where N is the number of file formats,
and M is the number of model classes.
1 + X + 1 + 1 + N methods, where X is the number of fields.
- Oliver