|
Hi Kent,
Thanks Robin and Steven. That makes total sense. I have been approaching my current implementation with a background in Java and JSPs not in Cold Fusion or even thinking about it by doing what I would call a poor mans version of web services (xml sans SOAP). I have been lucky enough to be using the AMF gateway for this. In the end I am left with the following network architecture:
For avoidance of doubt, I'm approaching this very much from a J2EE background as well, like yourself. To answer your question on "couldn't a client-side command just invoke server-side command" the answer is that yes, it could. I'm loathe to become religious about how the patterns should be used, and if your use-case merits the omission of the client-side delegate, then so be it. You're your own best architect.
However ..... I do prefer that my client-side commands are insulated from the implementation details of the service; that's a "nice" reason for the separation. However, as an RIA scales, more often than not I would find that a service that is exposed through my client-side delegate, has utility in more than one context. By way of example ... in an SMS messaging application, I may have a delegate method MessagingDelegate.sendSMS( message : MessageVO )
Now -- I have utility in my application to create a new message, reply to a message and to forward a message ... for new message; when replying to a message, I may want to prefix the message with ">" characters, same with forwarding a message. Furthermore, I may want new messages and messages I reply to to appear in an Outbox, but forwarded messages to go into a "Forwarded" folder (spare me some poetic license here). The point ... in all cases I have a need to simply call MessagingDelegate.sendSMS() but for each of these 3 use-cases the preconditions and the post-conditions around that delegate call are different.
With a Command/Delegate separation, the preconditions can be handled in the execute() method of the command, the post conditions can be handled in the onResult() method of the command, but the MessagingDelegate can simply expose the raw functionality of interacting with an SMS gateway and sending a message.
Another example of the utility of commands, is the ability to create base-commands for related use-cases in an application; I'll not provide convoluted example here, but there have been discussions on list about AuthenticatedCommands (commands that should only execute if logged in user with appropriate credentials is present in application state, with a dispatch to login screen if not the case). Again ... the Command is just a nicer level of abstraction for this behavior, than the delegate, which is really just "delegating the business service calls".
You may not agree ... and that's the great thing about Cairngorm; you don't have to. If you want to call services directly from the Command class, go for your life. You may at a later date find yourself refactoring towards the delegate, other times you may not. For me, experience of building lots and lots of Flash and Flex RIAs is that the separation is common enough that I feel comfortable having it, and now recommending it, as a starting point for archticture, and not something I refactor towards.
Flex
Side
Network
J2EE
Server ---------
---------- ||
---------
-------------------
------ | Command | <=>
| Delegate | <= || => | Command | <=> | Business Delegate |
<=> | EJBs | ---------
---------- ||
---------
-------------------
------ By doing this I allow
Struts to be a Command on the server side and can keep my Business Delegate
clean of any HTTPRequest or AMF processing knowledge. I guess the only
open question is would you still pass different Command objects to the Delegate
on the Flex side and have more then one function in the delegate that does
processing or would you keep it as a one to one relationship between Commands
and Delegates to avoid accidental calls of the wrong onResult handler? BTW Once I finally got a grasp on the basics of Cairngorm and Flex my development has been able to movie very fast. --
Steven Webster
Technical Director iteration::two
[EMAIL PROTECTED] Office: +44 (0)131 338
6108
Mobile: +44 (0)7977 216 223 This e-mail and any associated attachments
transmitted with it may contain confidential information and must not be copied,
or disclosed, or used by anyone other than the intended recipient(s). If you are
not the intended recipient(s) please destroy this e-mail, and any copies of it,
immediately. Please also note that while software systems have been used to try to ensure that this e-mail has been swept for viruses, iteration::two do not accept responsibility for any damage or loss caused in respect of any viruses transmitted by the e-mail. Please ensure your own checks are carried out before any attachments are opened. Yahoo! Groups Links
|

