aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Club Business Delegate with Command Pattern, pros-cons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Club Business Delegate with Command Pattern, pros-cons" Watch "Club Business Delegate with Command Pattern, pros-cons" New topic
Author

Club Business Delegate with Command Pattern, pros-cons

Deepak Shastri
Greenhorn

Joined: Aug 18, 2004
Posts: 22
Is it required to use a Business Delegate when using a Command Pattern ?
------------------------------------------------------------------------

By definition of a front controller with command handler patter
--------------------------------------------------------------
Implementing a front controller with a command pattern not only simplifies a session facade interface, it also keeps the controller implementation cleaner by encapsulating event- and request-handling tasks into smaller objects. It also enables Java platform events to be used as the bridge between Web- and EJB-tier controllers

Motivation to use a business Delegate
-------------------------------------
The Business Delegate may shield clients from possible volatility in the implementation of the business service API. Potentially, this reduces the number of changes that must be made to the presentation-tier client code when the business service API or its underlying implementation changes.


My question:
-----------
Cant we use the commandHandler itself to shield the presentation layer from the possible volatility as mentioned above ?
Lucy Hummel
Ranch Hand

Joined: Jul 22, 2004
Posts: 71
Hi Deepak,

You can do a lot.

You gain always something: postiv and negativ characteristics. ...

IMO: Decide by you own and state the benefit of your decision.

I would still use the Business Delegate.

Lucy
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Deepak

Welcome to JavaRanch.

Unfortunately your name does not comply with our naming policy. Please take a quick look at the rules and edit your profile accordingly.

Thank you!


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Deepak Shastri
Greenhorn

Joined: Aug 18, 2004
Posts: 22
Any more inputs on this....Guys I need views from this forum !!
John Arau
Greenhorn

Joined: May 12, 2005
Posts: 15
Hi, Deepak.

IMHO.If you mix the two types of code (request-handling , comunication with business service) you aren't shielding the business service API!

Alur's (the other Deepak) suggestion : Use Business Delegate whenever you have comunication with remote business compoments.(Page 302)

Thats's besides having a command pattern or not.

[ May 18, 2005: Message edited by: John Arau ]
[ May 18, 2005: Message edited by: John Arau ]
Deepak Shastri
Greenhorn

Joined: Aug 18, 2004
Posts: 22
Hi, John.
Thx for the answers
I did read Alur's explanation of having a Business Delegate when using Remote Business Components and shielding those remote exceptions and bo access code.

My doubts come after reading sun's blue-print.May be i dont quite understand it.

Typically as per Sun's Blue-prints, they have shown a Class Diagram
(http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/app-arch/app-arch5.html#1107803)

which depicts using both FrontController-->CommandPattern->Session Facade
and also a Business Delegate. The Business Delegate is being used only during data retrieval part.
They clearly mention that one shud use Business delegate when you are trying to retrieve data (Read). I am not quite convinced. Why cant we do without Business Delegate and use the same architecture of FrontController-->CommandPattern->Session Facade-->Business Delegate-->Business Objects for retreiving data.

As per sun's blueprint the explanation for using Business Delegate quite like Alur..But what is confusing me is that Business Delegate is not being used when request is coming via controller-->command-->sessionfacade-->business object. But only during retrieval.

You can refer to the explanation the above mentioned URL.

Any ideas here ?
Jamy Wang
Ranch Hand

Joined: Sep 21, 2003
Posts: 83
I think we can use both of them at the same time. Why not? Will they conflict?


Best Regards<br /> <br />SCJP1.4 SCJD1.4 SCEA
kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
HI All
petstore also says that a framework should always be preffered. But are we suppose to use framework like spring,struts,tapestry in scea part 2. If yes , do we have to show internal composition of chosen framework.

THanks
kundan


SCJP1.4,SCBCD,SCEA,CNA
Failures are practice shoots for success.
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
Deepak,
Besides decoupling business components from invoker, business delegate handles remote calls and convert remote exceptions to those that are suitable to the invoker.

Cant we use the commandHandler itself to shield the presentation layer from the possible volatility as mentioned above ?


Considering command pattern, CommandHandler is a receiver-- receiving the request and execute certain operations. In this case, I don't think the receiver can be responsible to shield the presentation layer...

My doubts come after reading sun's blue-print.May be i dont quite understand it.

Typically as per Sun's Blue-prints, they have shown a Class Diagram
(http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/app-arch/app-arch5.html#1107803)

which depicts using both FrontController-->CommandPattern->Session Facade
and also a Business Delegate. The Business Delegate is being used only during data retrieval part.
They clearly mention that one shud use Business delegate when you are trying to retrieve data (Read). I am not quite convinced. Why cant we do without Business Delegate and use the same architecture of FrontController-->CommandPattern->Session Facade-->Business Delegate-->Business Objects for retreiving data.


The document mentions about two approach: remote architect and local architect. For local architect, business delegate is not recommended. For the remote architect, a model can be an entity bean with remote access. In order for the view to access up-to-date data on this model, the view will need to use business delegate which uses service localor to look up the entity bean and access a snap shot of the entity bean state in the value object.


As per sun's blueprint the explanation for using Business Delegate quite like Alur..But what is confusing me is that Business Delegate is not being used when request is coming via controller-->command-->sessionfacade-->business object. But only during retrieval.

You can refer to the explanation the above mentioned URL.

Any ideas here ?


The controller creates an event, which is a command, then passes the event to the EJB controller which is a stateless session bean. In my opinion, if business delegate is being used, it should have been used here to decouple web tier from ejb tier.
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
Originally posted by vu lee:

The controller creates an event, which is a command, then passes the event to the EJB controller which is a stateless session bean. In my opinion, if business delegate is being used, it should have been used here to decouple web tier from ejb tier.


Still confused. So do you prefer using a BD instead of command pattern for a clean seperation of presentation tier and business tier ???

Hm.. This thread seems to throw some light to this issue :- http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=j2eepatterns-interest&F=&S=&P=23347

According to it, the commands are used to sheild the Facade from becoming a massive one. But if you guys look at the petstore eg, they are doing all the lookups for diff EJBs inside the EJBAction(check the OrderEJBAction), and what about the exception handling, which could have otherwise done on the BD to wrap the system exceptions to app specific exceptions ???

And also, is it wise to implement this pattern for the SCEA-2 assignment ???

[ May 25, 2005: Message edited by: Giju George ]
[ May 25, 2005: Message edited by: Giju George ]

SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Club Business Delegate with Command Pattern, pros-cons