What is a Pattern?
Patterns are a software engineering problem-solving discipline that emerged from the object-oriented community


GoF Design Patterns
The GoF described patterns as “a solution to a problem in a context.” These three elements—problem, solution, and context—are the essence of a pattern.
GoF Creational Design Patterns
Creational design patterns are concerned with the way objects are created.
Abstract Factory, Builder, Factory Method, Prototype, Singleton
GoF Structural Design Patterns
Structural patterns are concerned with composition or the organization of classes and objects, how classes inherit from each other, and how they are composed from other classes.
Adapter, Bridge, Composite, Decorator, Facade
GoF Behavioral Design Patterns
Behavioral patterns are concerned with the interaction and responsibility of objects.
Chain of Responsibility
Command, Interpreter, Iterator, Mediator, Memento, Observer
State, Strategy, Template Method, Visitor
Creational Design Patterns
Abstract Factory (Kit)
The Abstract Factory pattern’s intent is to provide an interface to use for creating families of related or dependent objects without actually specifying their concrete classes.
SCENARIO
The system needs to be independent of how its objects are created, composed, and represented.
J2EE Technology Features and J2SE API Association
J2EE Technology
Data Access Object (Sun)
Value Object Assembler (Sun)
Factory Method (Virtual Constructor)
The Factory Method pattern’s intent is to define an interface for creating an object but letting the subclass decide which class to instantiate.
In other words, the class defers instantiation to subclasses.
The client of the Factory Method never needs to know the concrete class that has been instantiated and returned. Its client needs to know only about the published abstract interface.
J2EE Technology Features and J2SE API Associations
J2EE Technology
javax.ejb.EJBHome
javax.ejb.EJBLocalHome
javax.jms.QueueConnectionFactory
javax.jms.TopicConnectionFactory
Singleton
The Singleton pattern’s intent is to ensure that a class has only one instance and provides a global point of access to it. It ensures that all objects that use an instance of this class are using the same instance.
SessionFactory in Hibernate,
Connection in JDBC
GoF Structural Design Patterns
Decorator (Wrapper)
An alternative to sub classing to extend functionality, the Decorator pattern’s intent is to attach flexible additional responsibilities to an object dynamically. The Decorator pattern uses composition instead of inheritance to extend the functionality of an object at runtime.
Facade
The Facade pattern’s intent is to provide a unified and simplified interface to a set of interfaces in a subsystem. The Facade pattern describes a higher level interface that makes the subsystem(s) easier to use. Practically every Abstract Factory is a type of Facade.
Proxy (Surrogate)
The Proxy pattern’s intent is to provide a surrogate or placeholder for another object to control access to it. The most common implementations are remote and virtual proxy.
GoF Behavioral Design Patterns
Chain of Responsibility
The Chain of Responsibility pattern’s intent is to avoid coupling the sender of a request to its receiver by giving multiple objects a chance to handle the request. The request is passed along the chain of receiving objects until an object processes it.
J2EE Technology Feature
RequestDispatcher in the servlet/JSP API
Command (Action or Transaction)
The Command pattern’s intent is to encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support rollback types of operations.
J2EE Technology Feature
MessageBeans
Iterator
The Iterator pattern’s intent is to provide a way to access the elements of an aggregate object sequentially without exposing its underlying implementation.
J2EE Technology Feature and J2SE API Association
J2EE Technology Feature
ValueListHandler
J2SE API
java.util.Enumeration
java.util.Iterator
Observer (Dependents or Publish-Subscribe)
The Observer pattern’s intent is to define a one-to-many dependency so that when one object changes state, all its dependents are notified and updated automatically.
J2EE Technology Feature and J2SE API Association
J2EE Technology
JMS (Java Message Server) Publish/Subscribe Model.
J2SE APIs
java.lang.Observable
java.lang.Observer
J2EE Patterns
The J2EE Patterns are broken down into the various sections that address the tiers (or layers) that make up an application:
Presentation Tier
The presentation tier encapsulates the logic required to service the clients accessing a system.
Business Tier
The business tier provides the services required by application clients and contains the business data and logic.
Integration Tier
This tier is responsible for accessing external resources and systems, such as relational and no relational data stores and any legacy applications.
Presentation Tier Patterns
The presentation tier encapsulates the logic required to service the clients accessing a system.
Presentation tier patterns intercept a client request and then provide facilities such as single sign-on, management of the client session, and access to services in the business tier before constructing and delivering the response back to the client
The patterns currently available for the presentation layer follow:
Composite View
Dispatcher View
Front Controller
Intercepting Filter
Service To Worker
View Helper
Business Tier Patterns
The business tier provides the services required by application clients and contains the business data and logic.
All business processing for the application is gathered and placed into this tier. Enterprise JavaBean (EJB) components are one of the ways to implement business processing in this tier.
Here are the patterns available for the business tier:
Aggregate Entity
Business Delegate
Composite Entity
Service Locator
Session Façade
Transfer Object
Transfer Object Assembler
Value List Handler
Value Object Assembler
Value Object


Integration Tier Patterns
This tier is responsible for accessing external resources and systems, such as relational and nonrelational data stores and any legacy applications.
A business tier object uses the integration tier when it requires data or services that reside at the resource level.
The components in this tier can use JDBC, J2EE connector technology, or some other proprietary software to access data at the resource level.
Here are the patterns available for the integration tier:
Data Access Object
Service Activator
Presentation Tier Patterns
Intercepting Filter
Forces
Each service request and response requires common pre-processing and post-processing
logging, authentication, caching, compression, data transformation
Adding and removing these “pre” and “post” processing components should be flexible
deployment time installation/configuration
Solution
Create pluggable and chainable filters to process common services such that
Filters intercept incoming and outgoing requests and responses
Flexible to be added and removed without requiring changes to other part of the application
Examples
Servlet filters for HTTP requests/responses
Message handlers for SOAP requests/responses
Front Controller
Forces
There is a need for centralized controller for view selection and navigation (Model 2)
based on user entered data
business logic processing
client type
Common system services are typically rendered to each request, so having a single point of entry is desirable
Example: Authentication, authorization, Logging
Can leverage filter pattern
Solution
Use a controller as an centralized point of contact for all requests
Promote code reuse for invoking common system services
Can have multiple front controllers, each mapping to a set of distinct services
Works with other patterns
– Filter, Command, Dispatcher, View Helper
View helper pattern
View helper pattern means that any logic that is not related to presentation formatting are encapsulated into helper components.
Composite view pattern
Composite view pattern means creating an aggregate view from atomic subcomponents.
Service to worker pattern
Service to worker pattern combines a dispatcher component with the front controller and view helper patterns
Business-Tier Design Patterns
Business Delegate Pattern
Forces
Business service interface (Business service APIs) change as business requirements evolve
Coupling between the presentation tier components and business service tier (business services) should be kept to minimum
It is desirable to reduce network traffic between client and business services
Solution
Use a Business Delegate to
Reduce coupling between presentation-tier and business service components
Hide the underlying implementation details of the business service components
Cache references to business services components
Cache data
Translate low level exceptions to application level exceptions
Service Locator Pattern
Forces
? Service lookup and creation involves complex interfaces and network operations
JNDI operation is complex
ex) PortableRemoteObject.narrow(.., ..)
? Service lookup and creation operations are resource intensive and redundant
Getting JNDI context
Solution
? Use a Service Locator to
– Abstract naming service usage
– Shield complexity of service lookup and creation
– Enable optimize service lookup and creation functions
? Usually called within Business Delegate object
Implementation Strategies
? Implementation strategies for Service Locator
– EJB Service Locator Strategy
– JMS Queue Service Locator Strategy
– JMS Topic Service Locator Strategy
– Combined EJB and JMS Service Locator Strategy
Data Transfer Object (Value Object)
Data Transfer Object, DTO in short, used to be called Value object. Data transfer object is an ordinary Java object that can be exchanged between tiers in order to exchange information. For example, when EJB client needs some information from EJB beans, the data should be returned in the form of Data transfer object intead of entity beans.
Data Transfer Object Assembler pattern
Data Transfer Object Assembler pattern assembles a composite value object from multiple data sources.
Composite entity pattern
Composite entity pattern represents a best practice for designing coarsegrained entity beans by grouping parent-dependent objects into a single entity bean.
Value List handler
Value List handler manages query execution, result caching, and results processing.
Integration-Tier Patterns
Data Access Object pattern
Data Access Object pattern provides an abstract layer between application and data source so that applications are shielded from data store specifics.
Service activator pattern
Service activator pattern facilitates asynchronous processing through Message driven bean.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

About This Site

Howdy! My name is Suersh Rohan and I am the developer and maintainer of this blog. It mainly consists of my thoughts and opinions on the technologies I learn,use and develop with.

Blog Archive

Powered by Blogger.

- Copyright © My Code Snapshots -Metrominimalist- Powered by Blogger - Designed by Suresh Rohan -