wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Reading from the database -- help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Reading from the database -- help" Watch "Reading from the database -- help" New topic
Author

Reading from the database -- help

Derick Potgieter
Greenhorn

Joined: Feb 19, 2004
Posts: 13
I want to know something about reading from the database.
I decided to do direct editing, reading from the database with RandomAccessFile.

Now there is two pieces of code i can use. I`m not sure which one would be better. code number one uses 2 for loops, creates a string array with all the values. Code number two makes an temp DatabaseSchema object. then reads the data byte by byte and set the values of the temp object.(this is all the columns in my database)

option 1 is a better loop and looks nice, only 10 line, but i still have
to convert the String[] to my DatabaseSchema
option 2 i can actually set the values on the DatabaseSchema directly but it is very long about 30-40 lines and looks dodgy(code is the same for all fields but only the object.set??? changes each time)

do you think that the examiner will mind about option 1 or should i
rather take the long way and be safe??

thanks
Derick
Jon Entwistle
Ranch Hand

Joined: Feb 20, 2003
Posts: 118
I don't think it is a case of what the examiner would mind - more a case of documenting important design decisions and being able to justify your choice. There is no single 'correct' answer. I would go whichever you are most comfortable defending, bearing in mind the overall goal of clarity and maintainability.

hth

Jon


SCJD, SCEA
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading from the database -- help
 
Similar Threads
want to skip database connection if condition is different.
Reading the record from the database
NX: B & S - Is this design too complex??
Data and DatabaseSchema initialization order
access database with java