File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 "", 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: 356

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.


Kai Witte's business website Kai Witte's private homepage
I agree. Here's the link:
subject: question about Data class
It's not a secret anymore!