The front controller design pattern means that all requests that come for a resource in an application will be handled by a single handler and then dispatched to the appropriate handler for that type of request. The front controller may use other helpers to achieve the dispatching mechanism.
UML Diagram Front Controller Design Pattern
- Controller : The controller is the initial contact point for handling all requests in the system. The controller may delegate to a helper to complete authentication and authorization of a user or to initiate contact retrieval.
- View: A view represents and displays information to the client. The view retrieves information from a model. Helpers support views by encapsulating and adapting the underlying data model for use in the display.
- Dispatcher: A dispatcher is responsible for view management and navigation, managing the choice of the next view to present to the user, and providing the mechanism for vectoring control to this resource.
- Helper : A helper is responsible for helping a view or controller complete its processing. Thus, helpers have numerous responsibilities, including gathering data required by the view and storing this intermediate model, in which case the helper is sometimes referred to as a value bean.
Let’s see an example of Front Controller Design Pattern.
Requested View: Teacher Authentication successful. Teacher View Requested View: Student Authentication successful. Student View
- Centralized control : Front controller handles all the requests to the Web application. This implementation of centralized control that avoids using multiple controllers is desirable for enforcing application-wide policies such as users tracking and security.
- Thread-safety : A new command object arises when receiving a new request and the command objects are not meant to be thread-safe. Thus, it will be safe in the command classes. Though safety is not guaranteed when threading issues are gathered, codes that act with the command are still thread safe.
- It is not possible to scale an application using a front controller.
- Performance is better if you deal with a single request uniquely.
This article is contributed by Saket Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Singleton Design Pattern | Implementation
- The Decorator Pattern | Set 2 (Introduction and Design)
- Decorator Pattern | Set 3 (Coding the Design)
- Flyweight Design Pattern
- Singleton Design Pattern | Introduction
- Java Singleton Design Pattern Practices with Examples
- Facade Design Pattern | Introduction
- Proxy Design Pattern
- Composite Design Pattern
- Prototype Design Pattern
- Bridge Design Pattern
- Mediator design pattern
- Template Method Design Pattern
- Builder Design Pattern
- Visitor design pattern
- Chain of Responsibility Design Pattern
- State Design Pattern
- Memento design pattern
- Null object Design Pattern
- MVC Design Pattern