• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Initial schema read

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Graham,

Welcome to JavaRanch and this forum!

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).

Regards,

Phil.
 
Graham Maloon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that it would be easier to call getMetaData, but would I not need to save the meta data somewhere?
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Good luck!
 
Graham Maloon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Robert Konigsberg
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

RK
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic