Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data and DatabaseSchema initialization order

 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic