The front controller design pattern is listed in several pattern catalogs and related to the design of web applications. It is "a controller that handles all requests for a website", which is a useful structure for web application developers to achieve the flexibility and reuse without code redundancy.
Purpose
Use this for larger systems in which you know that you will need as much flexibility as possible in managing many different views and commands.
Implementation
Application Controller
The application controller pattern is the pattern that permits the centralization of all view logic and promotes a unique process to define the flow of pages.
Purpose
Create a class to manage view logic and command selection.
Example
Here I’ll present a small, high-level sample of an Application Controller that manages a form compilation in multiple steps.
In Zend Framework, it can be thought of as homogeneous to Action Controllers (so that it can be easily put in an existing application’s infrastructure.) It usually does not take advantage of automated mechanisms like the ViewRenderer plugin to achieve a finer control. In fact, it does not map to a single domain action or a single view: the view is chosen on the fly and the domain model is seen through a Facade.
Implementation
Template View
In Template View, static HTML pages are defined and markers are used as placeholders within them for dynamic content on the page. When the page is requested, the markers are replaced with the dynamic content (ie, from a database or similar) by the underlying web server or framework.
Purpose
Create pages that manage display and user interface only, incorporating dynamic information into display markup with as little raw code as possible.
Implementation
Page Controller
Page controller is an alternative to front controller in MVC model.
Purpose
Lighter weight but less flexible than Front Controller, Page Controller addresses the same need. Use this pattern to manage requests and handle view logic if you want fast results and your system is unlikely to grow substantially in complexity.
Example
Zend framework Page Controller example
Implementation
Transaction Script
Transaction Script (TS) is the simplest domain logic pattern we can find. It needs less work to implement than other domain logic patterns and therefore it's perfect fit for smaller applications that doesn't need big architecture behind them.
Purpose
When you want to get things done fast, with minimal up-front planning, fall back on procedural library code for your application logic. This pattern does not scale well.
Implementation
Domain Model
At its worst business logic can be very complex. Rules and logic describe many different cases and slants of behavior, and it's this complexity that objects were designed to work with. A Domain Model creates a web of interconnected objects, where each object represents some meaningful individual, whether as large as a corporation or as small as a single line on an order form.
Purpose
At the opposite pole from Transaction Script, use this pattern to build object-based models of your business participants and processes.
Example
Webmail System.
Implementation
Summary
In this post, we looked at the following enterprise patterns: