aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Construct the Data file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:Construct the Data file" Watch "NX:Construct the Data file" New topic
Author

NX:Construct the Data file

Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
In many of past posts,I saw some ways from some people who build their own Data file(commonly called Data.java).
After seeing my URLyBird assignment,I've already had some ideas possibly naive about constructing the Data file:
---------------------------------------------
1)Data file implements the DBAccess interface;
2)Data class must be declared as public,it contains all data access functions.And the Data file also consists of:
a)Header class ->a class to describe the header info required in the insturctions.html;
b)Record class ->build each record in database file(db.db);
c)FieldInfo class->save each field info into database with required numeric type according to the instructions file;
------------------------------------------------
I don't know whether it's true or not.
Please professionals correct and help me,thanks.

Regards,
Richard.


Regards, Richard
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello Richard,
Following are my comments:
1)Data file implements the DBAccess interface - Correct
2)Data class must be declared as public,it contains all data access functions. Right again
And the Data file also consists of:
a)Header class ->a class to describe the header info required in the insturctions.html; - I called it DataSchema.java and I instantiate it within the Data.java class as a private member so that the header information can be used whereever needed.
b)Record class ->build each record in database file(db.db); -- You will see differing views on this in the forum. Some people have decided to cache the database in memory. I haven't. If you look at the signature of the methods in DBAccess (in my case DBMain) interface, you will see that records are being passed around as an array of strings. You may or may not need the Record class, but it nicely abstracts the value object pattern. Therefore, if you can use it naturally in your design, go for it.
c)FieldInfo class->save each field info into database with required numeric type according to the instructions file; - Again, nice object-oriented design, but do it only if you need it.
The way I am approaching the problem is inside-out, i.e., I wrote the DataSchema class first and as soon as I write a class of any substance, I write a test class for it, e.g., testDataSchema in this case just to see if it is indeed working the way it is supposed to. Nothing new, same unit testing concept. People use Junit as well. Anything is fine as long as you are satisfied that the class you have designed, works.
I then started coding data.java and yet haven't had a need to design the Record.java or FieldInfo.java classes that you mention above. I might, but I don't know that yet.
I did see a need to design a datahelper.java class that contains the utility static methods readFixedStrings and writeFixedStrings to read and write from/to the Random Access Files.
Design a little, code a little, test a little, refactor a little. Repeat the whole cycle.
Hope this helps.
Regards.
Bharat


SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
Hi,Bharat!
Thanks for your explaination for details.
[1]To my 2-a state,you just sayed that:
I called it DataSchema.java and I instantiate it within the Data.java class as a private member so that the header information can be used whereever needed.

But I am not able to know how to make it asa private member,so I still need a hint about it.
[2]As I don't sure the correctness about FieldInfo class and Record class,also it's the time that I am so excited to listen your encouragement using them.Thank you!I can try it.
[3]I think the Sun's assignment certain flexible but some limited.So I don't dare to take a risk during the assignment.Please suggest me the way of picking up the fields for making the database records.
Regards,
Richard.
*-----------------------------*----------------------------------*
Believe your common efforts is leaving,future achievement is coming.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:Construct the Data file