Java Design Patterns
Design patterns address the recurring design problems that arise in particular
design situations and propose solutions to them. Design patterns are thus
successful solutions to known problems. There are various ways to
implement design patterns.
These implementation details are called strategies.
The GoF (Gang of four ) pattern categories and scopes of design patterns.
****Creational Pattern****
Creational class-Creational class patterns use inheritance as a mechanism to achieve varying class instantiation.
example Factory Method.
Creational object-Creational object patterns are more scalable and
dynamic compared to the class creational patterns. Creational object patterns are more scalable and dynamic compared to the class creational patterns.
example Abstract Factory
Singleton
****Structural Pattern****
Structural class- Structural class patterns use inheritance to provide
more useful program interfaces by combining the functionality
of multiple classes.
example Adapter (class)
Structural object-Structural object patterns create composite objects by
aggregating individual objects to build larger structures.
The composition of the structural object pattern can be
changed at runtime, which gives us added flexibility
over structural class patterns.
example
Adapter (object)
Facade
Bridge
Composite
****Behavioral Pattern****
Behavioral class- Behavioral class patterns use inheritance to distribute
behavior between classes
example
Interpreter
Behavioral object- Behavioral object patterns allow us to analyze the
patterns of communication between interconnected
objects, such as the included objects of a composite object.
example
Iterator
Observer
Visitor
OTHER THAN GOF
Though the GoF patterns served well in designing and developing object-oriented systems
in both distributed and nondistributed environments, they were not created with
the distributed nature of large-scale enterprise systems in mind.
The authors have categorized the design patterns at seven architectural levels:
• Global
• Enterprise
• System
• Application
• Macrocomponent
• Microcomponent
• Object
The authors have two basic arguments.
The first is that software design involves making
choices, such as which details of an object should be abstracted and what should
be exposed, or which aspects of the objects are to be generalized and which one should
be specialized.
The authors’ second argument is that not all design patterns scale well at all seven
architectural levels. Each pattern has a set of applicable levels, which is an important
feature that must be considered when using the pattern.
J2EE Design Pattern
****Presentation Tier****
Decorating Filter/Intercepting Filter
An object that sits between the client and the web components. It pre-processes
a request and post-processes the response.
Front Controller/ Front Component
An object that accepts all the requests from the client and dispatches or routes
them to appropriate handlers. The Front Controller pattern may divide the
above functionality into two different objects: the Front Controller and the Dispatcher.
In that case, the Front Controller accepts all the requests from the client
and does the authentication, and the Dispatcher dispatches or routes them
to the appropriate handlers.
View Helper
A helper object that encapsulates data access logic on behalf of the presentation
components. For example, JavaBeans can be used as View Helper patterns
for JSP pages.
Composite View
A view object that is made up of an aggregate of other view objects. For example,
a JSP page that includes other JSP and HTML pages using the include
directive or the include action is a Composite View pattern.
Service To Worker
A kind of Model-View-Controller with the Controller acting as a Front Controller
but with one important point: here the Dispatcher (which is a part of the Front
Controller) uses View Helpers to a large extent and aids in view management.
Dispatcher View
A kind of Model-View-Controller with the controller acting as a Front
Controller but with one important point: here the Dispatcher (which is a part
of the Front Controller) does not use View Helpers and does very little work in
view management. The view management is handled by the View components
themselves.
****Business Tier****
Business Delegate
An object that resides on the presentation tier and on behalf of other presentation
tier components calls remote methods on the objects in the business tier.
Transfer Object/ Replicate Object
A serializable object for transferring data over the network.
Session Façade/Session EntityFaçade/Distributed Façade
An object that resides in the business tier, acts as an entry point into the business
tier, and manages the workflow of business service objects, such as session
beans, entity beans, and Data Access Objects. The Session Facade itself
is usually implemented as a session bean.
Aggregate Entity
An object (entity bean) that is made up of or is an aggregate of other entity beans.
Transfer Object /Assembler
An object that resides in the business tier and creates Transfer Objects on the
fly as and when required.
Value List Handler/Page-by-PageIterator/Paged List
An object that manages execution of queries, caching, and processing of
results. Usually implemented as a Session Bean, serving a subset of the
fetched result set to the client as and when needed.
Service Locator
An object that performs the task of locating business services on behalf of
other components in the tier. Usually present in the presentation tier, it is used
by Business Delegates to look up business service objects.
****Integration Tier****
Data Access Object
An object that talks to the actual underlying database and provides other application
components. It serves as a clean, simple, and common interface for
accessing the data, and for reducing the dependency of other components on
the details of using the database.
Service Activator
An object that helps in processing of business methods asynchronously.
No comments:
Post a Comment