D
dgront
There is my problem
* I have several (say: 5) classes : A, B, C. They rather hold some
data, but sometimes they do some simple operations on theirs data.
* The data can be stored is several various data formats: X, Y, Z, T, U
.... Several file formats can store data for a given class. Some file
formats hold more and some less information that is necessary to create
an instance of one of the classes: A B C
* The problem is to feed A, B or C with the data
My current solution:
- Each of the A, B, C classes has reading/writting method for each data
format:
A.readFromX()
A.readFromY()
A.readFromZ()
B.readFromX()
B.readFromY()
B.readFromZ()
.... (and writeTo.. methods)
Unfortunately, many of the formats do not handle all the necessary
data. For instance X has the half of the data and the rest is in Y. But
in the time of constructing object I don't have Y file. It can however
appear in the future.
So in my solution both X and Y readers create A and some of fields are
filled with some 'empty' contents (zeros, spaces, nulls...) If The
second file shows up, A.updateFromY() method is invoked.
In general my program works like that:
A.readFromX();
A.writeToZ(); // User can stop the program at this point - he will got
a Z file but some fields will be empty
for(; // Wait for user action. Also check if Y shows up
A.updateFromY()
A.writeToZ(); // all fields in Z are present
As you can see, creating a method:
A.readFromXY();
does not make sense, usually the two files: X and Y do not come
together
My solution works not that bad, but:
- there is an explosion of methods: three in each class for each data
format (readFrom, updateFrom, writeTo)
- file format specification is not fixed. Sometimes I face to a file
which my code fails to read. Then I have to trace all methods that
reads that file format in all the classes A, B, C.
- some of the fields of A may be defined both in X and Y. In general
the order:
A.readFromX();
A.updateFromY();
vs.
A.readFromY();
A.updateFromX();
makes a difference
Can anyone proppose a better solution? There is a bunch of my nevest
ideas:
- superclass that can read and write all the formats, like
metaparser.read(A,format_X)
is not a good choice for me - I want to keep A, B, C data private.
- at some point I used PostrgeSQL for this purpose. That was great, but
VERY inconvenient. I really need a single standalone program
Thanks in advance,
Dominik
* I have several (say: 5) classes : A, B, C. They rather hold some
data, but sometimes they do some simple operations on theirs data.
* The data can be stored is several various data formats: X, Y, Z, T, U
.... Several file formats can store data for a given class. Some file
formats hold more and some less information that is necessary to create
an instance of one of the classes: A B C
* The problem is to feed A, B or C with the data
My current solution:
- Each of the A, B, C classes has reading/writting method for each data
format:
A.readFromX()
A.readFromY()
A.readFromZ()
B.readFromX()
B.readFromY()
B.readFromZ()
.... (and writeTo.. methods)
Unfortunately, many of the formats do not handle all the necessary
data. For instance X has the half of the data and the rest is in Y. But
in the time of constructing object I don't have Y file. It can however
appear in the future.
So in my solution both X and Y readers create A and some of fields are
filled with some 'empty' contents (zeros, spaces, nulls...) If The
second file shows up, A.updateFromY() method is invoked.
In general my program works like that:
A.readFromX();
A.writeToZ(); // User can stop the program at this point - he will got
a Z file but some fields will be empty
for(; // Wait for user action. Also check if Y shows up
A.updateFromY()
A.writeToZ(); // all fields in Z are present
As you can see, creating a method:
A.readFromXY();
does not make sense, usually the two files: X and Y do not come
together
My solution works not that bad, but:
- there is an explosion of methods: three in each class for each data
format (readFrom, updateFrom, writeTo)
- file format specification is not fixed. Sometimes I face to a file
which my code fails to read. Then I have to trace all methods that
reads that file format in all the classes A, B, C.
- some of the fields of A may be defined both in X and Y. In general
the order:
A.readFromX();
A.updateFromY();
vs.
A.readFromY();
A.updateFromX();
makes a difference
Can anyone proppose a better solution? There is a bunch of my nevest
ideas:
- superclass that can read and write all the formats, like
metaparser.read(A,format_X)
is not a good choice for me - I want to keep A, B, C data private.
- at some point I used PostrgeSQL for this purpose. That was great, but
VERY inconvenient. I really need a single standalone program
Thanks in advance,
Dominik