• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: how to deal with the header information

 
Rico ZHANG
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Just want to know can I set the other header information as final static variables(coz tat will be much easier), or I should load it from the db file every time I need them.

i.e, the length of every field in a record,
the offSet of the Record 0..

things like this.

Hope that someone can help me

Thanks...
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the fact that the database file contains a metadata header conveys the idea of the possibility of adding or removing fields from the file in the future. Otherwise, what would be the point of describing the file with metadata, right?

In my case I am determining the header size every time I open the database file, and from there on, I use that value in all offset calculations. It means that, if tomorrow, a new field is added to the database, my design would be capable of automatically handling that.

Evidently, I would still need to retrofit my DAO objects and my GUI in order to deal with any new fields, but, at least the database would be capable of dealing with them.

At least that's my opinion. Perhaps, others can offer a different insight.
[ April 29, 2008: Message edited by: Edwin Dalorzo ]
 
Rico ZHANG
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Edwin.

I agree with you, and I was thinking about same thing as you...but I saw some guys here just hard coded something to make the application easier.. So I just thinking maybe I can do the hard coding for all the header information..

But I think you are right,,,
 
Quintin Stephenson
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I've gone for a dynamic approach with regards to the shema in a similar manner at Edwin. I read the meta data in the header and create a schema object. This object contains all the information that will dictate everything with regards to data (ie. data type, length postion in of column per records etc) and will ensure data ways ends up in the correct position in the datafile. It will also be used to affect my MVC model for the displayed GUI to my users.

My analysis of the data file gave me similar questions and conclusions(by the sounds of it) to Edwin. What redesign work would I have to go through if a new column was added (e.g. in my assignment I can see a need for a phone number column to be added). By the sounds of it some people are going for similar solutions to Andrew Monkhouse's book solution using a traditional hard coded Transfer Object design pattern.

I think you should be fine as long as you can justify it and remember to document it in your choices document as this is a major part of your assignment (your thought process and why you did certain things).

Cheers
Q
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we need to consider the extensiblity about adding or deleting a filed,
does this go too far from the requirement of this assignment?
 
Alexander Duenisch
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I even thought about transferring the dynamically obtained schema information (including the field names) to the client, so the client would also be capable of handling added/changed columns/fields correctly.
 
Aaron John
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Quintin Stephenson:
Hi All

I've gone for a dynamic approach with regards to the shema in a similar manner at Edwin. I read the meta data in the header and create a schema object. This object contains all the information that will dictate everything with regards to data (ie. data type, length postion in of column per records etc) and will ensure data ways ends up in the correct position in the datafile. It will also be used to affect my MVC model for the displayed GUI to my users.

My analysis of the data file gave me similar questions and conclusions(by the sounds of it) to Edwin. What redesign work would I have to go through if a new column was added (e.g. in my assignment I can see a need for a phone number column to be added). By the sounds of it some people are going for similar solutions to Andrew Monkhouse's book solution using a traditional hard coded Transfer Object design pattern.

I think you should be fine as long as you can justify it and remember to document it in your choices document as this is a major part of your assignment (your thought process and why you did certain things).

Cheers
Q


I am also doing the B&S assignment. For this schema object, how did you implement this schema object? I thought about:

- making the Schema object a singleton class so that metadata can be loaded only once (preventing unnecessary calls to loading metadata everytime a client accesses the database), and it can be made accessible throughout the entire application. But I came to the conclusion that we have a data layer interface for database operations, so having a singleton Schema object in the data layer kinda goes in the opposite direction.

- making a new interface called Metadata, which the Data class implements in addition to DBMain. The interface contains methods like getColumns() etc. The problem is that I don't know how to prevent unnecessary calls to loading metadata everytime a client connects to the database (ideally I only want metadata to be loaded once and once only), and I'll need to have two references to the interface to call the data layer (DBMain and Metadata), when ideally I would only really want one.

What have others implemented? Please share your ideas. Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic