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.
I have one more question. Listen, I'm done my Data class which implements DBAccess.
And I want to make a business class to wrap the Data class. so that I try to use it both standalone and network.
I made a interface which included booking, search method. and I would implement LocalBusiness and RemoteBusiness. LocalBusiness directly use Data class. RemoteBusiness is just adaptor for LocalBusiness. when the client is executed in standalone mode then I just use LocalService. when the client is executed in network mode then I use RemoteService.
Please note to me If there is something that I missed. ^__^
Thanks for regards.
Primary Java Developer.<br /> <br />Living in Korea. I hope to meet lots of friends over the internet.<br /> <br />Thanks for all guys in this site who helped me to get a SCJD. <br />Cheers !
The code you have submitted will not compile because method signatures in your Service interface reference RemoteException and this exception is checked exception, thus methods in your LocalService class have to reference that RemoteException as well, which is wrong. I believe you need to think how to resolve that problem
Joined: May 26, 2008
Thanks for replay.
It doesn't occure any compile error. And compile error is not important in that code, most important thing is architecture.
And compile error is not important in that code, most important thing is architecture. In my opinion making use of the decorate design pattern to encapsulate your LocalServiceImpl object in your RemoteServiceImpl is a great idea. More so I have designed a similar service/business layer.
More so I think a major advantage is the all your business logic only exists in one place (LocalServiceImpl) which is neat and clean design and further promotes ease of maintainability.
I think you're on the right track!
Joined: Aug 27, 2008
Sorry, yes, you are right there are no compile time errors... so, from the architectural point I don't think it is a good idea to implement both LocalService and RemoteService from the java.rmi.Remote interface, thus you say "LocalService is a Remote" class. This is just my opinion, but I think the decoupling has to be made on interface level not on class level.
The local Service make no use of "Remote", but rather a higher level IOException. I consider extending "Remote" from your local interface to be wrong. You'll find many threads on this if you search on the forum about throwing IOException from your Services class.
My suggestion is: * Create similar interface as provided by Sun, but with all methods throwing RemoteException in addition. * Make your implementation of Sun interface to implement this new interface as well. * Make your remote interface to extend this new interface (then it will be empty) * As to remote implementation class - initialize Sun's interface with local implementation class.