- Business Delegate
- Forces
- Solution
- Consequences
- Sample Code
- Related Patterns
Consequences
- Reduces coupling, improves maintainability
- Translates business service exceptions
- Improves availability
- Exposes a simpler, uniform interface to the business tier
- Improves performance
- Introduces an additional layer
- Hides remoteness
The Business Delegate reduces coupling between the presentation tier and the business tier by hiding all business-tier implementation details. Managing changes is easier because they are centralized in the Business Delegate.
The Business Delegate translates network or infrastructure-related exceptions into business exceptions, shielding clients from the knowledge of the underlying implementation specifics.
When a Business Delegate encounters a business service failure, the delegate can implement automatic recovery features without exposing the problem to the client. If the recovery succeeds, the client doesn’t need to know about the failure. If the recovery attempt fails, then the Business Delegate needs to inform the client of the failure. Additionally, the Business Delegate methods can be synchronized, if necessary.
The Business Delegate is implemented as a simple Java object, making it easier for application developers to use business-tier components without dealing with the complexities of the business-service implementations.
The Business Delegate can cache information on behalf of the presentation-tier components to improve performance for common service requests.
The Business Delegate adds a layer that might be seen as increasing complexity and decreasing flexibility. However, the benefits of the pattern outweigh such drawbacks.
Location transparency is a benefit of this pattern, but it can lead to problems if you don’t keep in mind where the Business Delegate resides. A Business Delegate is a client-side proxy to a remote service. Even though a Business Delegate is implemented as a local POJO, when you call a method on a Business Delegate, the Business Delegate typically has to make a call across the network to the underlying business service to fulfill this request. Therefore, try to keep calls to the Business Delegate to a minimum to prevent excess network traffic.