Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface to implement

 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

The specifications say that data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
public String [] readRecord(long recNo)
public void updateRecord(long recNo, String[] data, long lockCookie)
public void deleteRecord(long recNo, long lockCookie)
public long[] findByCriteria(String[] criteria);
public long createRecord(String [] data)
public long lockRecord(long recNo)
public void unlock(long recNo, long cookie)

I would prefer to implement the high level data access class with methods like: addRoom(room),removeRoom(recNo),findRooms(name,location) etc. So the low level record manipulation is encapsulated.

However the specs above seem to restrict this, can anyone confirm if theres a way around this while meeting the specifications?

thanks,
James
 
Anita S�rensen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented a high level data access class that uses data.java for direct database access, and it seems that this is a very common solutions. I don't think you have to worry as long as you remember to document your desitions.
 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi;

your specification say : data access class must be called "Data.java", ... , and must implement the following interface ( XXX).

the specification do not prevent you from adding more method to the data class, it is just tell you to implements the the interface provided , you can add more method to the data class as
close DB method , get All record , ...

M_darim
SCJP, SCJD ( in progress ... )
the school is the biggest life
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A more elegant way, like Anita suggested, is to add another class of higher level of abstraction...

Just like you would do for any other similar system... some DAO, some business logic using them...
[ November 07, 2007: Message edited by: Alex Turcot ]
 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It might be an elegant solution but I think it may go against the instructions:

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

I interpret this to mean that Data is the high level facade through which data is accessed and it must implement the interface DBAccess. So if we do implement a higher level class have we not followed instructions?

J.C
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Clarke:

It might be an elegant solution but I think it may go against the instructions:

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


Not at all, nothing prevents you from having a class called, lets say :
Operations with 2 methods:
- search
- book

Then, its calling your "data access class called data, that is in the package suncertify.db implementing the interface."
Data Acces class: only means that this is the class controling the access to your data.

If I follow your logic, then no other class would be allowed to exist and call Data.java, so you would also add SWING object there ? I'm pushing it, just to show my point.

The interface is your contract with your database. Beyond that, you want to keep a good OO design. In respect to that, you don't want to add business related methods in it.

Also, your assignment probably tells you that you must call lock before updating... You definitely want a business object with that logic.

Alex
[ November 07, 2007: Message edited by: Alex Belisle Turcot ]
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Alex Belisle Turcot. You can have another higher level class that uses your Data class. But you can also add more methods to your Data class in addition to those that implement the methods from the required interface.
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got a lot of time on your hands.

Check out this lengthy, but interesting discussion of the 2-tier vs.3-tier debate :

Should lock methods be callable by the client
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic