Enterprise Integration Zone is brought to you in partnership with:

Jagadeesh is a DZone MVB and is not an employee of DZone and has posted 27 posts at DZone. You can read more from them at their website. View Full User Profile

J2EE Design Patterns: Quick Introduction

05.27.2013
| 8211 views |
  • submit to reddit

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?

  1. Patterns are observed through experience.
  2. Patterns are typically written in a structured format.
  3. Patterns prevent reinventing the wheel.
  4. Patterns exist at different levels of abstraction.
  5. Patterns undergo continuous improvement.
  6. Patterns are reusable artifacts.
  7. Patterns communicate designs and best practices.
  8. Patterns can be used together to solve a larger problem.
  9. Patterns have their own pros and cons

What are the Pros and Cons of Design Patterns?

Pros:

  1. Combination of Patterns can offer reusable architectures / artifacts.
  2. Helps in the improvement of developer community by standardizing the design principles.
  3. Capture expert knowledge and design trade-offs on the recurring problems and make the expertise widely available.
  4. Reusability with out having to re-invent the wheel.
  5. Helps provide a high-level language for discussing design issues in software industry.
  6. Provides much of the design work upfront.
  7. Design Patterns can be applied at any point during the project life cycle.
  8. Design Patterns provide a standard vocabulary for software designers.

Cons:

  1. Some of the Design Patterns are complex in nature.
  2. They are simply validated by experience and discussion.
  3. Design patterns may increase or decrease the understandability of a design or implementation.
  4. 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 -

  1. Context – Describes the environment under which the Pattern exists
  2. Problem – Describes the recurring design issue
  3. Forces – Helps us understand the driving forces of adopting a Design Pattern
  4. Solution – Describes the solution and its elements (Structure and Strategy) in detail
  5. Consequences – Identifies the pros and cons of using a pattern pattern
  6. Sample Code
  7. Related Patterns (if any)

References:

http://www.developer.com/design/article.php/1474561

http://developer.yahoo.com/ypatterns/page.php?page=lifecycle

http://ocw.mit.edu/NR/rdonlyres/Electrical-Engineering-and-Computer-Science/6-170Fall-2005/96A8B7AF-3C20-4D92-8F07-EFA537FD82C2/0/lec18.pdf

Books:

Core J2EE Patterns – Best Practices and Design Strategies by Deepak Alur, John Crupi, Dan Malks.

EJB Design Patterns by Floyd Marinescu

Published at DZone with permission of Jagadeesh Motamarri, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)