• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Db file reader question

 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am going to start on my assignment. I have a question on the code that reads the db file. Not to get into too much detail (I hope I am not going against the rules, if so, please tell me so), I have a html file with requirements. Among others, it describes a file in a great detail - what fields are there, what is the length in byes of every field, their names and so on. My questions is - this is so specific, is it ok to just hardcode the values in my db reading code? The names, the lengths, and offset could all be hadrcoded as constants, and the code to read the file would be much simpler. I could of course do it dynamically, but does this make any sense? Will the points be cut if I do one or the other?
Regards,
Raf
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Raf!

You know, I myself also hardcoded the values. I created an interface called DBConstants that has all the values, and this interface is also implemented by the Data class. But the code that I created for the DBFileReader tool reads the file dinamically, just so everybody can use it, and more people may make use of it.

I justified my choice of hardcoding the values saying that nothing was mentioned about the database schema changing, so I thought there were no problems, and the code would be simpler.
 
Naveen Narayanan
Ranch Hand
Posts: 114
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My motivation was, friend Roberto’s amazing DBFileReader, to go for dynamic file reading
in the assignment.

Now I feel like, probably gone a bit extra than the requirements.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I read my database schema completely dynamically. My main argumentation was it would become very easy to use the Data class (I created for handling the room bookings) to handle a similar file with customers, hotels,... So it makes your Data class completely independent of the database file you are using (without adding too much complexity to the Data class).

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic