File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Data and DatabaseSchema initialization order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Data and DatabaseSchema initialization order" Watch "Data and DatabaseSchema initialization order" New topic
Author

Data and DatabaseSchema initialization order

Olena Golub
Ranch Hand

Joined: Jan 17, 2005
Posts: 113
Hello All,
I am trying to understand the initialization order of the Data and the DatabaseSchema.
For example the standalone mode. I don't use the Data direct. I have wrapped it into Adapter (DataAdapter).
After the application is started and the user chooses the database location, the DataAdapter recieves the database location.
And before the Data initialization it will initialize the DatabaseSchema.
Initialization of the DatabaseSchema looks like:
Read the magic cookie and check it. If this are not correct notify the DataAdapter and user and close the application.
If the magic cookie is correct, than read all information about records.
After this done, the Data will be initialized. Data will recieve the reference to the database (RandomAccessFile) from DatabaseSchema.

The advantage:

1. I don't need to extend the Data if i need to have a method something like String[] getColumnNames().


Or the second idea is to read the DatabaseScheme in Data file and define some static methods in Datashema:
public static String[] getColumnNames().
How do you think about it? What is idea okey? Or do you have another ideas?
Thanks a lot!

Olena
[ April 04, 2005: Message edited by: Olena Golub ]

SCJP 1.4<br />SCJD 1.4 (in progress)
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11490
    
  95

Hi Olena,

Remember that there is not much reuse planned for the current code, and you will not get extra marks for doing anything outside the requirements.

With this in mind, I would probably read the schema within Data class, and if, in the future someone wants to handle the schema, then they can work out what methods they want to add (and whether they want to define an additional interface to define that functionality).

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data and DatabaseSchema initialization order