CHAPTER 12 ■ ENTERPRISE PATTERNS
- The command and control layer processes the request from the user. Based on this
analysis, it delegates to the business logic layer any processing required in order to
fulfill the request. It then chooses which view is best suited to present the results
to the user. In practice, this and the view layer are often combined into a single
presentation layer. Even so, the role of display should be strictly separated from
those of request handling and business logic invocation. - The business logic layer is responsible for seeing to the business of a request. It
performs any required calculations and marshals the resulting data. - The data layer insulates the rest of the system from the mechanics of saving and
acquiring persistent information. In some systems, the command and control
layer uses the data layer to acquire the business objects with which it needs to
work. In other systems, the data layer is hidden as far as possible.
Figure 12–1. The layers or tiers in a typical enterprise system
So what is the point of dividing a system in this way? As with so much else in this book, the answer
lies with decoupling. By keeping business logic independent of the view layer, you make it possible to
add new interfaces to your system with little or no rewriting.
Imagine a system for managing event listings (this will be a very familiar example by the end of the
chapter). The end user will naturally require a slick HTML interface. Administrators maintaining the
system may require a command line interface for building into automated systems. At the same time,
you may be developing versions of the system to work with cell phones and other handheld devices. You
may even begin to consider SOAP or a RESTful API.
If you originally combined the underlying logic of your system with the HTML view layer (which is
still a common strategy despite the many strictures against it), these requirements would trigger an
instant rewrite. If, on the other hand, you had created a tiered system, you would be able to bolt on new
presentation strategies without the need to reconsider your business logic and data layers.
By the same token, persistence strategies are subject to change. Once again, you should be able to
switch between storage models with minimal impact on the other tiers in a system.