J2EE Design Pattern : Introduction
- What is J2EE Design Pattern?
- What is Coupling?
- Type of J2EE Design Pattern
- Good Design Vs Bad Design
- J2EEArchitecture Multi Tier and Multi Layer
- When and How to Apply Patterns
- Design Pattern Notation
|What is Design Pattern?|
“Pattern” as the name suggests, means series of events occurring in a definite order. The patterns can be found in Java and J2ee technologies also. Many times, we find that there is a particular way of tackling a problem. This way is easy and has been used many times successfully by a number of people earlier also. This method becomes a pattern.
Patterns Defined: The patterns can be defined in many ways. You can find the definitions of patterns in many good books.
“Design patterns are recurring solutions to design problems.”
why do need to use design patterns?
Design patterns have a number of advantages like
- Once described, any level engineer can use the pattern.
- They allow for reuse without having to reinvent in every a project.
- They allow to better define system structure.
- They provide a design vocabulary.
- They provide reusable artifacts.
- Patterns can form frameworks that can then be used for implementations.
What is a context?
A context is the environment, surroundings, situation or interrelated conditions within which something exists.
What is a problem?
A problem is an unsettled question, something that needs to be investigated and solved. Typically, the problem is constrained by the context in which it occurs.
What is a Solution?
Refers to the answer to the problem in a context that helps to resolve the issues.
|What is Coupling?|
Every design or application has
- 1. Function
- 2. Non- Functional (Maintainablity,scalability,realiabilty,decoupling)
You should not start an application immediately but plan a solution for the problem. The Solution plan is called a design.
A Good design is very important for successful execution of projects.
Design Pattern helps to achieve following Non-functional attributes
- Development efficiency
Coupling is a measure of how dependant classes are on other classes
To reduce coupling:
- Hide the implementation of the classes
- Couple to the abstract interface of a class
- Reduce the number of methods in the interface of the class
- Consider the coupling of the entire system rather than just between individual classes
|Type of J2EE Design Pattern|
J2EE design patterns are grouped under five heads:
- Client Tier
- Presentation Tier Patterns
- Business Tier Patterns
- Integration Tier Patterns
- Resource Tier
Client Tier :
This tier represents all device or system clients accessing the system or the application. A client can be a Web browser, a Java or other application, a Java applet, a WAP phone, a network application, or some device introduced in the future. It could even be a batch process.
Presentation Tier :
This tier encapsulates all presentation logic required to service the clients that access the system. The presentation tier intercepts the client requests, provides single sign-on, conducts session management, controls access to business services, constructs the responses, and delivers the responses to the client. Servlets and JSPs reside in this tier. Note that servlets and JSPs are not themselves UI elements, but they produce UI elements.
Business Tier :
This tier provides the business services required by the application clients. The tier contains the business data and business logic. Typically, most business processing for the application is centralized into this tier. It is possible that, due to legacy systems, some business processing may occur in the resource tier. Enterprise bean components are the usual and preferred solution for implementing the business objects in the business tier.
Integration Tier :
This tier is responsible for communicating with external resources and systems such as data stores and legacy applications. The business tier is coupled with the integration tier whenever the business objects require data or services that reside in the resource tier. The components in this tier can use JDBC, J2EE connector technology, or some proprietary middleware to work with the resource tier.
Resource Tier :
This is the tier that contains the business data and external resources such as mainframes and legacy systems, business-to-business (B2B) integration systems, and services such as credit card authorization.
Presentation Tier Patterns
Following is the list of Presentation Tier Design Patterns.
- 1. Intercepting Filter
- 2. Front Controller
- 3. Context Object
- 4. Application Controller
- 5. View Helper
- 6. Composite View
- 7. Service to worker
- 8. Dispatcher View
Business Tier Patterns
Following is the list of Business Tier Design Patterns.
- 1. Business Delegate
- 2. Service Locator
- 3. Session Façade
- 4. Application Service
- 5. Business Object
- 6. Composite Entity
- 7. Transfer Object
- 8. Transfer Object Assembler
- 9. Value List Handler
Integration Tier Patterns
Following is the list of Integration Tier Design Patterns.
- 1. Data Access Object
- 2. Service Activator
- 3. Domain Store
- 4. Web Service Broker
|Good Design Vs Bad Design|
|J2EEArchitecture Multi Tier and Multi Layer|
|When and How to Apply Patterns|
- Some literature suggests that patterns be proactively applied to designs
- Some literature suggests using fewer patterns and only refactoring them into a design
- Either way, you should look for a design balance of flexibility and simplicity
- After understading design pattern tutorial, you might be inclined to try and solve every problem with a design pattern
- Design patterns are not a golden hammer to solve every problem
Design Pattern Selection
There is no one best pattern, rather there are specific patterns that apply to particular problems:
- Pattern selection should be based on similarities between the context, the problem, and the forces of the
pattern and a design problem
- Multiple patterns might be used to solve a particular problem
|Design Pattern Notation|
Design Pattern Notation