aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DataAccess class for remote/local 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 "DataAccess class for remote/local" Watch "DataAccess class for remote/local" New topic
Author

DataAccess class for remote/local

Renato Mascardo
Greenhorn

Joined: Jul 03, 2003
Posts: 8
Here is a quick question in regards to the Data classes. My design has the following:
1) Data Class --> Provided by Sun
2) DataAccess Interface implements Remote --> Includes all the method signatures of the Data class
3) DataAccessLocal implements DataAccess
4) DataAccessRemote extends UnicastRemoteObject implements DataAccess, Unreferenced
The question I have is that my DataAccess class implements Remote even though I don't really use it for the DataAccessLocal. I don't see any problems with that design but is there a better way to do that? Should I add another interface that extends DataAccess and implements Remote?
Thanks!
-Renato Mascardo
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Either way will be fine. I had the same design and it worked fine. Like you said have Remote extended in the interface is fine and won't hurt in local mode.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Renato Mascardo
Greenhorn

Joined: Jul 03, 2003
Posts: 8
Thank you Mark. The only weird thing is that in my DataAccessFacade, I need to wrap the DataAccess calls in RemoteException try-catch even though its running in local mode. I'm assuming that your code does the same thing and it seems not necessary in Local mode.
What do you think?
-rjm
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Renato,
I've been struggling with the same dilemma, I think I�ve come to the conclusion that the DataAccess interface should be a generic interface, and hide the actual implementation from the DataAccessFacade. My decision for this has been based upon the JDBC interface, it provides a generic interface �Connection� which hides the actual implementation (data access).
The issue I still undecided upon is whether the interface should throw a generic exception like Exception or IOException. Mark has suggested in previous posts that all the methods could be defined to throw Exception, I like the idea as it would enable future implementations to throw other exceptions than just RemoteException, DatabaseException etc, my only concern is that I don�t think it is a good idea to catch Exception as it tends to be a bucket, and the javadocs will not provide the developer with much information.
Jason.
Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
In the above statement,there is a state:
2) DataAccess Interface implements Remote --> Includes all the method signatures of the Data class

Who can explain that from 2 points?
1.May a interface implement another interface?
2.Includes all the method signatures of the Data class This mean that all the methods containing into the Data class can be moved to the new class?
Wait for your reply.
Regards,
Richard


Regards, Richard
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Hi Richard,
May a interface implement another interface?

Probably a typo. An interface cannot implement anything. It can, however, extend other interfaces.
Includes all the method signatures of the Data class This mean that all the methods containing into the Data class can be moved to the new class?

No, Data still has the methods it requires. However Renato has created an interface which almost matches perfectly the methods in Data.
I would ignore this if I were you. Renato is doing the Fly By Night Services assignment, which has some requirements that you do not have.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataAccess class for remote/local