C. Koch

Greenhorn
+ Follow
since Feb 24, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by C. Koch

Roel De Nijs wrote:
In my solution the suncertify.properties is only accessed from my gui-package and I use the path to the database file to initialize my Data class.



So what do you do about your magic cookie? It sounds like your Data class is specifically designed to serve hotel room records from a file with a (hardcoded?)magic cookie xyz and a primary key "roomnumber", so it's reusability is limited but it needs very few configuration. My Data class is able to read any file following the given data file specification and doesn't care if said file contains records consisting of 6 fields with no primary key or 9 fields with a primary key combined out of three fields. To do that it has to get a valid cookie for the used schema to compare with the given file and information which fields make up the key. So my class is very flexible but requires more configuration to achive that goal.

cheers
Christian
Hi Roel,

I don't understand why you have to pass a magicCookie and a set of strings to your getInstance method in your Factory.



My approach is quite generic. You can pass any primary key (Set<String>) and magic cookie to it, and it configures itself (using the file header) according to your constructor arguments. So my idea was to read the configuration in my main() method and than construct a Database according to it. If I read the .properties file while constructing the database I get a somewhat tight coupling between my database and my suncertify.properties. I am only allowed to use a single .properies file, and from an architectural point of view I do not feel that coupling a database with a file containing gui and network configuration is clean design.

cheers
Christian
Hi,

for my assignment (URLy Bird) I am using a rather generic database class. My assignment only states:

"Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:[....]"

To avoid using a singleton I use a factory method with the signature

where Data is package-private (originally it was a private static inner class, but that way I'd have a file Data.java containing no instantiable class called Data, which I guess would only be legal if this was a lawyer exam, and not a programming one....(actually you can't name your class Data.java even if you want to, but thats another story))
The assignment does not say anything about providing a default constructor, so is it possible to get away without one, or do I have to provide one, thus ruining my generic approach? My second question is about the size of the database. I use a cache, which means my Data object grows in size linear to the data file, inevitably resulting in an out of heap space error for very big files. anyone else has done this, or do I need to check the file size and enable / disable the cache accordingly?

Thanks in advance
Christian