Ever since the first program was written, designers and developers have tried to leverage existing designs and reuse code whenever possible. With the advent of n-tier architectures and object-oriented languages the need to create baseline patterns from proven designs has become tantamount to the creation of systems that are flexible, maintainable and extendable. This article will provide insight into the use of design patterns to capture knowledge and expertise and apply them to recurring problems.
For the purpose of this article, design patterns will be used generically as a label for patterns in general. A design pattern provides a description of a solution to a recurring design problem. The description defines the key aspects of a common structure through a schema of collaborative components. The components and their relationships are explained through class diagrams, sample code and narrative. Each pattern details when it applies, its constraints and tradeoffs.
Patterns in general should be viewed as a repository of knowledge to capture experience which when combined form a language to resolve common software development problems. The two most prominent repositories of patterns to date are Design Patterns - Elements of Reusable Object Oriented Software by Gamma, Helm, Johnson and Vlissides - also know as the gang of four, and Patterns of Enterprise Application Architecture by Martin Fowler. Both provide detailed patterns that should form the basic structure to any organization's design repository. The patterns are based on OO concepts and can be implemented in any OO language, JAVA, C#, C++, etc.
Aside from the books just mentioned, other catalogs of patterns are available from Sun Microsystems, IBM, Oracle and Microsoft. These catalogs focus on two main frameworks, J2EE and .NET. Both frameworks can be greatly enhanced through the use of patterns. The vendor-specific patterns are well documented and proven over many projects. The core J2EE design patterns provided by Sun Microsystems form the foundation for all other J2EE patterns. The Struts framework produced by the Apache Jakarta Project is a fantastic repository of best practices presented using design patterns which build on J2EE technologies but are not a part of the J2EE standard.
The following patterns overview is based on the Design Patterns by Gama et al. The base 23 patterns are segregated into three areas by purpose: creational patterns, structural patterns and behavioral patterns. Creational patterns deal with object creation. Structural patterns relate to object composition and behavioral patterns deal with the interaction between objects.
The patterns are further classified by scope between objects and classes. Class patterns focus on their static relationship between classes at compile time, while object patterns address the relationship with objects at runtime.
Figure 1: Design Pattern Space
- The creational patterns produce concrete classes by separating the construction of complex objects from their representations. The abstract factory pattern produces an interface without specifying any concrete classes.
- The structural patterns work on the interfaces between objects to help decouple an abstraction from its implementation which can be used to let classes with incompatible interfaces work together.
- The behavioral patterns control the behavior of how objects relate to themselves and other objects. Object behavior can be based on state, request handling and object interaction.
The best way to get started using design patterns is to dive into the patterns and get a feel for the problems being solved. By selectively implementing patterns into your designs upfront, you will alleviate the need for constant refactoring and in turn create applications that are based on proven best practices.
New development tools are coming to market that embrace patterns as part of the design process. The OptimalJ product by Compuware implements Sun's core J2EE design patterns which are embedded into the application framework. Microsoft's Visual Studio product includes enterprise templates that include both design and code patterns.
In conclusion, design patterns are the best way to reduce development time, improve quality and embrace best practices. They provide a common language for designers, architects and developers to share knowledge across platforms and problem domains.
Register or login for access to this item and much more
All Information Management content is archived after seven days.
Community members receive:
- All recent and archived articles
- Conference offers and updates
- A full menu of enewsletter options
- Web seminars, white papers, ebooks
Already have an account? Log In
Don't have an account? Register for Free Unlimited Access