aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Command or Business Delegate over RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Command or Business Delegate over RMI" Watch "Command or Business Delegate over RMI" New topic
Author

Command or Business Delegate over RMI

Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 72
Hi everyone,

I'm new to the JCD (and new to this forum, so hi! and have spent the past week thrashing out my design for my B&S assignment

While pondering England's depressing defeat yesterday evening (in the pub afterwards) I suddenly had an inspiration of brilliance regarding the command pattern.

My thinking here is that I could use the command pattern to encapsulate each request the client makes to the server therefore reducing the coupling between the two.

Now, if I was using sockets for my project I wouldn't hesitate in moving forward with this design - it saves having to worry about a protocol (too much anyway) and is easily implemented.

The question is though, is my original idea of defining an interface at the server end and adding a business delegate layer to control access to/from the server more suited to my RMI approach. (In other words, calling update, find, read etc... directly from the client). After all, with RMI I effectively have direct access to the client so I'm questioning whether the command pattern is trying to go against what RMI is all about or is it in fact a brilliant idea which affords easy future expansion/development, employs another buzz wordy pattern for my choices.txt and tidies up how my client and server interact.

I guess this could be seen as more of a general RMI 'best practise' question but one that I'd be interested to find people's views on.

I open it to the floor....
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11285
    
  59

Hi Chris,

Welcome to JavaRanch and this forum.

Personally I think that the command pattern is not a very good fit for RMI. One of the major advantages of RMI is to make it appear to client programmer that a remote method is local. But when you add the command pattern you are stepping back from that direct access - to my mind this defeats the purpose.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 72
This was exactly my concern - the big question now is to justify using it over RMI, which I'm not so sure I can.

I like the some of the advantages the command pattern approach affords (especially regarding its simplicity, from a maintenance perspective and for future expansion) although I suspect I'm going to have to go with the sockets approach as, like you say, it goes against RMI's grain to restrict the remote call to one 'doIt' type method.

I'm now trying to think of dis-advantages of going down this route, although am struggling a little.....

*insert help below*
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11285
    
  59

Hi Chris,

It sounds like you are trying to work out how to use the command design pattern in your solution, rather than working out a top level architecture and then deciding which patterns fit within it.

Personally I think this is dangerous - trying to force the use of a particular design pattern can result in awkward and/or hard to understand code.

If you really wanted to use the command design pattern in your application, you might want to look at whether it can be used for communication between the various components of an MVC (and, if you use the observer design pattern between the model and the view, you may find that it almost forces you to use the command design pattern - although that is not the only place in an MVC that can use the command design pattern).

Regards, Andrew
Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 72
Hi Andrew,

Yeah, you're right. I need to take a step back, go back to the drawing board (not that I ever left it :-) and re-think my design.

I initially decided to use RMI, I was then considering changing that to use sockets to get the CP in there. I guess I've broken 'design rule' number one here.

Right then, where's that whiteboard.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Command or Business Delegate over RMI
 
Similar Threads
Enthuware doubt : Buisness Delegate
Do we need to show BD & Service Locator in Sequence Diagrams?
Managed Bean as service locator
[mock][J2EE pattern][Business Delegate]
Business Delegate with JSPs