I was thinking of reading the first part of the file in a singleton that will then keep the schema of the file. This can be accessed by the Data class. Should this be available to the client.
Only if you need it, but it's probable. Two comments:
1) Do you really need a Singleton? Anyway, I think it'll look more natural, to the clients of your Data class, to call some getMetaData() method on their Data instance, instead of calling some static MetaData.getInstance(), IMO. 2) By "client", I guess you mean your business tier, wherever it lies (client-side or server-side).
Joined: Jul 23, 2004
I understand that it would be easier to call getMetaData, but would I not need to save the meta data somewhere?
I suspect you don't need the metadata on the client. If you're handling the B&S certification, you may not have requirements to have variable metadata. I'd handled that by documenting, loosely, what would be required to add a field to the database, showing where all the different parts are. That was documentation for any new developer coming in. So just assume that the metadata is not changing and go from there.
Also regarding metadata as a Singleton, what if you wanted to open multiple databases? It might be better to use composition to make the metadata an attribute of your data class.
SCJP 1.4 (91%)<br />SCJD 1.4 (376/400, 94%)
Joined: Jul 23, 2004
Thanks for your responses.
I think it would be nice to show the field names on the client and therefore the metadata. If I were to put the reading of the schema into the Data class, I would have to make it static. Is that a good idea?
Joined: Jun 23, 2004
I still don't think making it static is a good idea. Again, what if you have two databases open? What would you do then? Keep the metadata as an attribute of your data class. The same data object you access through your middle-tier is the same one that could deliver the metadata.
A singleton database connection might be reasonable and has different implications. It's easier to manage two databases, each with their own metadata than two databases and one static metadata.