wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes question about Data class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "question about Data class" Watch "question about Data class" New topic
Author

question about Data class

Lara McCarver
Ranch Hand

Joined: Dec 09, 2003
Posts: 118
I am doing B&S 2.3.3. It says:

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:

package suncertify.db;
public interface DBMain {
...


So I have a class:



My question is, does Data need to be the class the class that directly accesses the data, or is it OK to have another class that does the actual interaction with the database, and Data contains an instance of that class.

There are several reasons I want to do this is:

1. I would like to have Data use my HomemadeDB class, which has read() and isLock() methods which return an EOF exception if I have gone past the end of the database, and then the read method in the Data class can catch these errors and translate them to RecordNotFound exception.

2. I am still thinking about having Data's read() method use a Database Cache object, though I haven't really decided.

I think this is OK because Data is still a data access class... but the DatabaseCache object and my HomemadeDB object are also data access classes.
Kai Witte
Ranch Hand

Joined: Jul 17, 2004
Posts: 354
hello,

yes, that would be ok (according to instructions in 2.3.2, but most likely in 2.3.3 as well).

Generally, don't try to make up things they may not like. Just be careful with explicit "must"s. There are no implicit "must"s, even when the consequences of some (valid) interpretations are crazy. For example many ppl did not implement delete and insert methods (throwing UnsupportedOperationException), and all of them passed with high scores.

Conan


Kai Witte's business website Kai Witte's private homepage Mock exam / preparation kit reviews
 
jQuery in Action, 2nd edition
 
subject: question about Data class
 
Similar Threads
Adds new methos to BDMain
What shall Data class really do?
B&S Appropriate Use of Exception
a question about the interface
B&S - Must RMI and Local DB interfaces need to be different?