Thursday, September 29, 2011

FrontController and Facade design Pattern

In this blog we are going to discuss the difference between FrontController and Facade design pattern. If one looks at there definition, they both look similar and at times during implementation they can be mixed up. 

Definition wise :


FrontController :  "The Front Controller pattern defines a single component that is responsible for processing application requests. A front controller centralizes functions such as view selection, security, and templating, and applies them consistently across all pages or views. Consequently, when the behavior of these functions need to change, only a small part of the application needs to be changed: the controller and its helper classes. -http://java.sun.com/blueprints/patterns/FrontController.html "
FrontController solves the problem of common functionality distributed across the components by centralizing the functionalities at one common component. For example, in a web application , any request hits an entry point servlet. That servlet can act as FrontController by encompassing the responsibility of common features which need to be applied to every request like logging, security etc.

Facade: The Facade pattern defines a higher-level business component that contains and centralizes complex interactions between lower-level business components. It provides clients with a single interface for the functionality of an application or application subset. It also decouples lower-level business components from one another, making designs more flexible and comprehensible.  Facade aggregates various complex business processes and provides client with a simple and unified interface to interact with.

A Facade component does not have any business logic. It merely invokes series of lower level components. On the other hand, client does interacts directly with FrontController. Once it receives any request, it inspects the request and decides what to do with the request. And it does has some business logic.

1 comment: