aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design feedback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design feedback" Watch "Design feedback" New topic
Author

Design feedback

Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
Hi everyone
After much chopping and changing I have decided on the following design for my data client: any comments very welcome, please feel free to criticize, my ego can take it
I have two interfaces


Now the Data class implements DataInterface and my RemoteData class implements RemoteDataInterface. I am using RMI and my RemoteData instance itself contains a Data instance.
On the client side I have a factory that churns out DataInterface type objects for use by the client. In the case of a local connection the factory returns a Data object and for a remote connection it gets a RemoteData instance from the server then wraps it in a class called RemoteDataAdapter which also implements DataInterface and returns that to the client app.
The RemoteDataAdapter class catches all the RemoteExceptions, IOExceptions actually (I use IOException in the interface so that my application is not tied to RMI but could use sockets or any other transport mechanism.) but throw RemoteException in the implementing RemoteData class. My RemoteDataAdapter then converts my IOExceptions to DatabaseExceptions to comply with DataInterface.
Finally but DataInterface instance is passed by the connection factory to a class called DataAccess that performs the tasks of book, search etc. on behalf of the client.
I know alot of others have had two interfaces but had both DataInterface and RemoteDataInterface throwing RemoteException, or IOException, as the remote interface extended the local one but I really didn't like this as I would then be throwing and catching exceptions in local mode that would never actually be thrown and caught and thought this would be confusing for the reader. Now everything ultimately just throws DatabaseException.
This also means I am free to vary my implementation for the remote connection without breaking the interface used by DataAccess. In other words I am free to change the implementation of RemoteDataAdapter to use any reference I like and catch whatever I want so long as it conforms to DataInterface.
Feel free to blow it out of the water if you wish.
Have a good weekend all
Many thanks
Sam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design feedback