• 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

Club Business Delegate with Command Pattern, pros-cons

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Deepak Shastri
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any more inputs on this....Guys I need views from this forum !!
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think we can use both of them at the same time. Why not? Will they conflict?
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic