J2EE Design Patterns: Quick Introduction
What are Design Patterns?
A Design Patterns describe an optimal solution to a common recurring design problem within a specific context.
Every author defined Design Patterns in slight variations but the essence is the same. The best in my opinion is by Christopher Alexander – “Each pattern is a three-part rule, which expresses a relation between a certain context, a problem, and a solution”
What are some of the characteristics of Design Patterns?
- Patterns are observed through experience.
- Patterns are typically written in a structured format.
- Patterns prevent reinventing the wheel.
- Patterns exist at different levels of abstraction.
- Patterns undergo continuous improvement.
- Patterns are reusable artifacts.
- Patterns communicate designs and best practices.
- Patterns can be used together to solve a larger problem.
- Patterns have their own pros and cons
What are the Pros and Cons of Design Patterns?
- Combination of Patterns can offer reusable architectures / artifacts.
- Helps in the improvement of developer community by standardizing the design principles.
- Capture expert knowledge and design trade-offs on the recurring problems and make the expertise widely available.
- Reusability with out having to re-invent the wheel.
- Helps provide a high-level language for discussing design issues in software industry.
- Provides much of the design work upfront.
- Design Patterns can be applied at any point during the project life cycle.
- Design Patterns provide a standard vocabulary for software designers.
- Some of the Design Patterns are complex in nature.
- They are simply validated by experience and discussion.
- Design patterns may increase or decrease the understandability of a design or implementation.
- They can decrease understandability by adding indirection or increasing the amount of code.
Common Structure of Design Pattern
All Design Patterns adopt a common structure that presents various attributes for a given Pattern. In general, a Design Pattern consists of the following attributes -
- Context – Describes the environment under which the Pattern exists
- Problem – Describes the recurring design issue
- Forces – Helps us understand the driving forces of adopting a Design Pattern
- Solution – Describes the solution and its elements (Structure and Strategy) in detail
- Consequences – Identifies the pros and cons of using a pattern pattern
- Sample Code
- Related Patterns (if any)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)