Reading the �Core J2EEPatterns � Best Practices and Design Strategies�, I don�t find it convincing enough to use Business Delegate. The relationship between a business delegate and a business service is 1-1. A business delegate is on the presentation tier, and a business service is on the business tier. In my opinion: If we implement a business service as an EJB, the business service has a stub on the presentation tier, which KINDA works a business delegate. I don�t find it convincing enough to use business delegates although I can find some minor reasons to use it. Why Business Delegate: 1. Business delegate translates business tier exceptions into more presentation friendly exceptions. Why Not Business Delegate: 1. The service look up code is always on the presentation tier no matter we place the service look up code in either a Servlet or a business delegate. Why bother to create an extra business delegate? 2. According to the book, business delegate is supposed to hide underlying implementation detail of business service from the presentation tier. In my opinion: with a business service as an EJB, the Remote Interface of the business service only exposes the business methods to the presentation tier. Since an EJB can achieve the same result, why do we need business delegate? �Clients may need to implement caching mechanisms for business service information� (Page 248). Would anyone give me some explanations? Thanks much in advance. I know you folks are the best. :-)
X. John Wen<br />SCEA, SCWCD, SCJP, MCAD.NET, MCDBA, MCP
Hi John, I was not reading about the new Business Service pattern, however, as far as you justify your point of view, I think it would be no problem in the exam. I also found BD very useful. It creates a layer between client and business, so that, clients don't know at all if the business methods are located remotely or locally. Note that one of the problems is with RemoteException (that I suppose you also have to deal with, in the interface defined by the Business Service pattern). If you don't implement BD, clients must be aware of RemoteException, so you lock clients with a REMOTE business implementation. If you decide latter not to use EJB, because you don't want to spend money/resources in a application server or whatever, you have to change client code. This would be simplified if you have the business access encapsulated in just one place - Business Delegate.
Business Delegate takes care of how to delegate the reuqest to the next tier/system. So the Business Delegate will have logic to itegrate with another tier, all the implementation would go into one business delegate. All the Business delegate methods will be called from withing the tier. If ther is any change between those, it will be done in business delegate only, not all the individual calls. Look at petstore, try to understand how it is being applied.