Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package Design

 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, Here Jerry again.

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.

 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerry,

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
 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roman.

Thanks for replay.

It doesn't occure any compile error.
And compile error is not important in that code, most important thing is architecture.

please focus on that one. ^__^
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jethro Borsje
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Justin, I think it's a good idea! I have implemented the same architecture a couple of days back.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I rather did something like that:



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.

Regards,
Alex
 
Jevgeni Zhukov
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic