• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

B&S: server-client communication

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
It's been a while, I am stuck in this problem for almost a week now and hope you guys can help me out. I am implementing a socket based solution, and in a previous thread, some fellows suggested me a brilliant idea regarding server-client communication thru the use of command Pattern. Everything went fine until I was struck by this!? Let me explian the problem clearly so you can get better understanding of what I am up against. It won't take long time..promise
My client controllers don't care whether it's serving a local or remote client:

All the load lies on the ContractorServices argument which is in fact an interface that describe the services contract:


public interface ContractorServices {
public void book(int recNo, String id) throws AlreadyBookedException,
ContractorNotFoundException,IllegalAccessException,
ContractorServicesException;
//more services methods


I also have default implementation of this interface:

Things looked good, until I finished coding my RemoteContractorServices class. This class open a socket connection to the server, hence it has the potential of throwing IOException(s) of it's own, which are far from being related to the business logic, I considered coding remote GUI controllers that are simply duplicates of the local controllers but have the capability of cathcing IOException. However, I thought this will increase the number of unnecessary classes and may violates these must requirements as well:

Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all


and

Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs


That's why I chose to keep my controllers intact:

Currently, I dealt with this problem. but I am not sure if represents good OOP and good exception handling strategy:


Please help me out, I can't go further and worsen the situation

Thanx in advance
Hatim
 
author and jackaroo
Posts: 12200
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 Hatim,

From what I can see, your ContractorServicesException is thrown for any problems accessing the data in stand-alone mode. As such, having the ContractorServicesException thrown for any problems accessing the data in networked mode makes sense as well.

Off topic: one thing I would recommend though, is changing your exceptions such that they used chained exceptions. An article on this is here. Using this, your code would change from:To:All the (minimal) work will be in having a second constructor for your Exception, however once you have done this it means that your stack trace will be much more valuable if ever anyone needs to debug your code.

Regards, Andrew
 
hatim osman
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thanx alot, that helped alot, honestly I was going quite far with this, I was considering the use of a RuntimeException. But your remarks make more sense.

Hatim
 
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic