Objects in the business logic layer combine data with business rules, constraints, and activities. Business objects should be separated from DAOs, VOs, and the deployment layer, such as enterprise beans, to maximize the possibility of reuse. Business objects often use and coordinate the activities of multiple data access objects.
Business objects should be deployment independent and self-contained. Any Java Naming and Directory Interface (JNDI) resource (e.g., database connections) that a business object needs to function should be provided by its deployment wrapper. This allows business objects to be redeployed (or republished, if you will) as anything you would like, including enterprise beans, RMI services, CORBA services, Web services, applets, and applications.
Some developers add the BO suffix to business object names, but this is not a technical requirement.
Layered initialization is a pattern you will commonly use when you have different varieties of the same object. For example, most applications have different types of users. As shown in figure 5.5, you might have trust customer users, corporate customer users, banking support users, application administrator users, and so on. All these users share commonality but also have aspects that are unique.
When the same business object might have to produce different outputs or use different inputs, you will most likely use the adapter pattern. Consider the example shown in figure 5.6, a reporting business object that has several different delivery mechanisms—e-mail, printing, Web site publishing—but all other processing is the same. Having an adapter to represent the input consolidates a lot of code.
Like the adapter pattern, the strategy pattern is used when the activities of a business object are likely to vary according to the context. However, the adapter pattern leaves the activities of a class constant while dynamically varying its inputs and outputs, and the strategy pattern makes the activities of a class dynamic while using constant inputs and outputs. It's largely a difference in perception of "who's the client." Figure 5.7 illustrates the strategy pattern.