Designing interfaces more effectively

Hi,

I'm having a requirement, where i need to design an interface. Currently we are having one concrete class which is going to implement that interface.

for ex :

publicinterface myintf

{

public Object getMyData(String name)throws NameNotFoundException, DataAccessException;

}

Here the interface throws two exceptions, NameNotFoundException and DataAccessException,

But i think this is a bad design, i know that the concrete class that i have now will interact with the database, thus may cause DataAccessException.

But it seems i am trying to inject dependancy from my concrete class to the interface, because may be other classes which is going to implement the same interface in future may not be hitting the db for getting the data.

Could you please tell me what and all i need to consider for exception clause while designing the interface.

[1100 byte] By [rameshrsamya] at [2007-11-27 8:48:51]
# 1

> But i think this is a bad design, i know that the concrete class that i have now will interact with the database, thus may cause DataAccessException.

I don't think that's necessarily a bad design. "DataAccessException" to me sounds like a problem accessing data; it doesn't imply that there's a database involved. That said, you may want to examine the "layer" your interface is in and throw a single exception related to that layer that wraps underlying exceptions as the root cause.

~

yawmarka at 2007-7-12 20:56:53 > top of Java-index,Java Essentials,Java Programming...