J2EE Design Patterns: Getting Started - Common Design Patterns at a Glance
(Page 2 of 4 )
Each of the tiers has its own set of Design Patterns. However, there are certain patterns that stand out and are used the most. Following are three of them:
- Model-View-Controller Pattern (MVC)
- Data Access Object Pattern (DAO)
- Data Transfer Pattern (DTO)
The first pattern is applicable to the client and server-side presentation tier. The last two apply to the server-side domain model; the last one is also the pattern that provides the conduit for data between the layers.
Model-View-Controller Pattern (MVC)
MVC can be defined as “a software architecture that separates an application's data model, user interface, and control logic into three distinct components so that modifications to one component can be made with minimal impact to the others.” An application, regardless of whether it is a desktop or web application, has three major parts: the data model, presentation logic and flow logic. In the MVC pattern, the Model does the data model, the View handles the presentation logic and the Controller does the flow/application logic.
Data Access Object Pattern (DAO)
A Data Access Object abstracts and encapsulates the access to the data source. A class that implements the DAO pattern manages the connection with the data source to obtain and store data. In short, all the data access related operations can be implemented using the DAO pattern.
Data Transfer Object Pattern (DTO)
The Data Transfer Object (DTO) pattern is simple: rather than make multiple calls to retrieve a set of related data, a single call can be made, retrieving a custom object that includes all the required data for the current transaction. The data is encapsulated in the form of an object. Many times, the DTO is a reflection (in the literary sense) of the data model and hence can be used to do data operations without tightly coupling the business model with the data model.
That was a bird’s eye view of the most common design patterns. In the next section, I will be implementing MVC, DAO and DTO patterns in a real world example.
Next: J2EE Design Patterns in the Real World >>
More JavaScript Articles
More By A.P.Rajshekhar