This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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
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.
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
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