Hi!
I am working on the B&S assignment and I thought that I had made a clean design...until i started to change things..now I think I need to consult on what is a recommended java approach to the design.
I have a Database interface that is the interface to the database. There are 4 methods.
book
findByName
findByCity
listAll
I have a RemoteDatabase inteface that is the interface to the database using a remote client. It has exactly the same signature as Database, except for that all methods throw RemoteException.
book throws RemoteException
findByName throws RemoteException
findByCity throws RemoteException
listAll throws RemoteException
Then I have a Client interface that is the common client interface for the Controller to use (my model in mvc). Implementing classes of Client are RemoteClient and DirectClient, and client has also the exact signature as Database has. This is good, because the controller only needs to know that its working with a Client, but can be unaware of that it is a Direct or Remote client.
Now... what I earlier did is that the RemoteClient caught the RemoteExceptions and displayed an error to the customer, and did not propagegate them further, since that would break the Client interface (with expections). Then I figured... I think it is more correct to propage these errors all the way to the GUI, wrap them as ControllerExceptions in the Controller and catch and show in the GUI itself.
So... then I need the RemoteClient to actually follow the RemoteDatabase interface exactly...but the DirectClient to follow the Database (without the remoteexceptions). Now Client can no longer be an interface to these two...and I cannot use it nicely in my Controller class anymore.
Also I seem to have so many interfaces and classes that have the same setup of methods...
Client, RemoteClient, DirectClient, Database, RemoteDatabase, DatabaseImpl, RemoteDatabaseImpl.
Maybe I'm not completely off, but I feel a bit like i'm painted in a corner here.
What would be a proper java way of using the interfaces and classes?