• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

DataAccess class for remote/local

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Renato Mascardo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic