WEB presentation patters: Page controller and Front Controller
Jeffrey Han
December 2005
Summary:
Details about the prevalent patterns of page controller and front
Controller. With experiences of three running systems, summarizing some
Tips about when to and how to use one of them. In addition,
Intercepting pattern is introduced as a supplementary.
Contents
Introduction
Page Controller
Front Controller
Intercepting Pattern
Conclusion
Introduction
In the past three applications,
The page controller and Front Controller all have been adapted for
Change of details. Utilizing the template pattern, the page Controller
Realizes a stable framework, the future expansion of system can added
In the child classes without modifying the integral framework. The page
Controller can process the complicated business centrally. In Asp.net,
Handler and command are the main parts in this framework. It will bring
Flexibility to the later maintenance. Certainly, some performance issue
Will occur. About the intercepting pattern, as I know, the retriable
Filter chain is my favorite. Each filter node is dependent business
Logic; you can configure the order or makeup according your
Requirements.
Page Controller
As started, the application
Shocould control the same business in the same place. If you Application
Doesn't have much more complicated business, you cocould use it. First
The page controller may be thought from the template patter in gof.
All know, the template Pattern Defines a framework in his parent class;
Some concrete realization will be in the respective child class. In
Asp.net, we make a class named "basepage" generally, below is
Related code:
Public Class Basepage:Page
{
Virtual Protected Void Pageloadevent(Object Sender,System.Eventargs E)
{}
Protected Void Page_load(Object Sender,System.Eventargs E)
{
If(!Ispostback)
{
Pageloadevent(Sender,E);
}
}
}
A virtual class in the class
Basepage, the concrete business can be realized in the parent class.
Since the page controller is a web presentation pattern, we want some
General page tags in the base page. We cocould use the file of ". inc ";
You can find your Web controls here and make them into ded into
Concrete pages. Hence we have both business logic and WEB presentation
In our general class (basepage ).
Front Controller
In application realization, if a business logic
Is so complicated that we can consider current pattern. We shoshould know
The simple factory well, and pattern of command. There are two parts in
This pattern: command and handler.
Originally, we can have an independent command
Function inheriting from the parent command which has the interface
"Execute". Utilizing the command factory to produce the related
Command, the request will be processed by HTTP handler. Actually, we
Will have a classical framework including the top, left and Central
Parts totally. So we can make some changes about the current pattern.
Some ideas are as the following:
1.The
Actual Application shoshould have two types of command, one is
Redirecting and another will load the left navigations and top
Navigations according to the parameters in the XML Configuration
Profile.
2.Another
Concern, We shoshould have this functionality: If the left navigation is
Activated, there shocould be no change with the top part in
Framework. Regarding the performance, it will be helpful.
3.Because
Of the structure of three parts, so we shoshould have deep understood
About the request. When you send a request in the left or top part
Framework, the entire framework will be posted back.
Intercepting
Pattern
About
This topic, I think it adapt to some other business about security and dependent
Business Objects configured by the XML nodes. In my opinion, this method adapts
To the requirements changed frequently. You can abstract the business to build
Some dependent components, and configure your customized business for
Special requirements by different order or different components.
Conclusion
In conclusion, there is no mature architecture
Page layer in Asp.net from my opinion. The above patterns can meet most requirements.
If the requirements don't need complicated logic, you can integrate some common
Parts by PAGE controller pattern. To others you can use the pattern of front
Controller. And the intercepting pattern can add the additional flexibility. On
The other hand, the system will have a obscured design, so you shoshould adapt
Your Design According your concrete requirements. (end)