Hi all,
Gosh, I'm stuck with a design question that has bothered me all night. I think I don't see the wood for the trees...
My Data class (URLyBird 1.2.1 to be specific) does delegate all IO operations to a DataFile class which is a wrapper around the RAF. DataFile holds a private static reference to the RAF and synchronizes access to it. I want allow several Data instances as well as several DataFile instances. So far so good - I hope ;-)
How does DataFile know the path to the db file?
If it is passed in the constructor I would have to check whether the file (static reference!) has already been opened because I allow several DataFile instances -> ugly hack.
I could drop the "several instances solution" and have one static reference in Data. This would make sure the constructor is only called one -> lame solution. This simply shifts the problem to the Data class that also needs to know the file path.
DataFile could read the path directly from the properties.file. As a consequence, modification of the file location at runtime would not be possible because the properties file would have to be updated first -> horrible.
Should I maybe go for the Factory Method
pattern and provide the file path in the concrete factory method e.g. createDataFile(
String path)?
Any helpful comments are welcome.
Best regards,
Marcel