• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about Data class

 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic