File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes implementing interface methods within another interface method 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 "implementing interface methods within another interface method" Watch "implementing interface methods within another interface method" New topic
Author

implementing interface methods within another interface method

Heilien Tsui
Greenhorn

Joined: Dec 08, 2008
Posts: 20
Hi everyone,

I am working on urlyBird project

here are some of method defined in the interface

public String [] read(int recNo) throws RecordNotFoundException;
public void update(int recNo, String [] data) throws RecordNotFoundException;
public void delete(int recNo) throws RecordNotFoundException;
public void lock(int recNo) throws RecordNotFoundException;
public void unlock(int recNo) throws RecordNotFoundException;
public boolean isLocked(int recNo) throws RecordNotFoundException;

In the implementation class.

is it good design if i do the following?

public void update(int recNo, String [] data) throws RecordNotFoundException{

//calling read(recNo), so it can check if the RecordNotFoundException is thrown
read(recNo) ;
....


}

same for other methods with RecordNotFoundException.

Or, it is better to write a separate piece of code for checking the record valid for each method that throws RecordNotFoundException

Which way will be better ?

thanks for the time reading my question








SCJP 5, SCJD 5, SCWCD 5, SCDJWS 1.4, SCBCD 5, SCEA 5
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

Hi Heilien,

I checked in a private method if the recNo was valid. I didn't used the read-method to check this (because that would be extra file I/O which is not necessary).

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: implementing interface methods within another interface method