This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question about the methode defined in the interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question about the methode defined in the interface" Watch "Question about the methode defined in the interface" New topic
Author

Question about the methode defined in the interface

Stef Widmer
Greenhorn

Joined: Jun 16, 2004
Posts: 17
Hi,I've got a qustion about the methodes in the DBMain interface.
There is a methode "find" which returns an array of integers (the record keys) and a methode called "read" which takes one record key and returns an array of strings if the record cound be found. But there is no methode like "getAllRecords" or so.
When a client starts, I wanted to read all records from the db file display theme in the client's JTable. But for that the client needs to call the "find" methode without any argument first and then calls for each key returned the "read" methode. This seems to me as a big overhead.
But my assignment tells me, that I have to implement the DBMain interface in a class called "Data". For exchangeability I assume I should not extend the data class with public methodes I've designed (e.g. getAllRecords).
What do you think about this?
------------
Thanks for any help

Stef Widmer
[ June 16, 2004: Message edited by: Stef Widmer ]
Omar Kalaldeh
Ranch Hand

Joined: Jun 08, 2004
Posts: 58
Hi,

As I see it you have to choices:
1-Use the Adapter design pattern, where you can put your getAllRecords method in your adapter class.

2-Extends the DBMain interface and add to it the method getAllRecords, and implements that Extended interface.

See this thread for more information about extending DBMain interface

Big Moose Saloon

I hope this answer will help you.


Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question about the methode defined in the interface
 
Similar Threads
Where to place RecNo?
[URLyBirdHotel 1.3.3] Couldn't I use Data.java interface class?
Exceptions handling during find operation.
Do i have to create new exception for my interface
No readAll methods provided