Club Business Delegate with Command Pattern, pros-cons

Deepak Shastri

Greenhorn

Posts: 22

posted 11 years ago

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 ?

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

Posts: 83

posted 11 years ago

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

Posts: 323

posted 11 years ago

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

Posts: 208

posted 11 years ago

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...

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

Posts: 333

posted 11 years ago

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 ???

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 ???