My.ADVISOR.com Sign-In
ID
Password

Member Center / Sign-Up
   
SUBSCRIPTION STATUS
If you are a subscriber to this publication, sign-in to access locked articles. To subscribe or renew go to www.AdvisorStore.com.
Go to Article
Advanced Search 

ADVISOR VIEW

Foster Code Reuse Via Design Patterns

Design patterns help make software components understandable and extensible.

By Tony Higham, Technical Editor

When using an object-oriented analysis and design approach to a project, the design phase is the most complex and time-consuming step. You have to figure out what objects you need and how they should interact to meet the requirements. However, you can speed up the design and development phases by reusing parts of previous applications and adapting them as necessary.

Code reuse is by no means a new idea, and was practiced before object-oriented languages appeared on the scene. In its most primitive form, code reuse takes the form of copying code from an original application and pasting it into a new application. Eventually, we started putting code into libraries to form software components. Code reuse on this level works for individual developers, and possibly across teams of developers. However, reusability across an enterprise, or by the general public, faces some challenges.

The lack of widely accepted best practices leads many developers to build their own, reinventing the wheel. Another issue is the "not invented here" syndrome. There are many reusable components out there, but developers are wary of using components they didn't develop because they can't see the code.

To be truly reusable, software components must be easily understood and extensible. This is where design patterns come in. Design patterns are the result of building architecture research done by Christopher Alexander in the 1970s. After studying many buildings, Alexander determined that certain patterns of design were common to buildings that survived the ages. His research concluded that you could design better buildings by applying generic solutions to common problems. These patterns weren't meant to be the perfect solution to the common problems, but a best practices approach that could be adapted to fit any given situation.

In 1995, four software developers (Gamma, Helm, Johnson, and Vlissides) started thinking about Alexander's research in terms of software design. The Gang of Four (GoF), as they're known, defined 23 patterns to solve common problems developers face in software design.

Making designs understandable

Because the design patterns are well documented and accepted best practices, using them in the design of your application makes the application easier to understand, and stimulates development of software components. Design patterns are expressed in words and diagrams, not code. Applying a familiar standards-based diagramming approach such as the Unified Modeling Language (UML) lets you easily understand and accept the design and underlying code.

Software components based on patterns are understandable, and therefore much more acceptable to a developer for potential reuse. In addition, components aren't tightly coupled with the applications they compose, and are extensible, improving the likelihood of code reuse.

Adapting and combining patterns

It's important not to take a purist approach to the use of patterns. Although completely changing a pattern lessens its understandability, modifying a pattern slightly to fit the environment in which it is being used makes sense. The concept of adapting and combining patterns as you see fit is important in the successful use of patterns.

You can also combine patterns to solve multiple issues simultaneously. For example, in my Web applications I use the State pattern inside the Command pattern to verify that a given command is valid for the present application state. So, if the user is on the checkout page (in the Checkout state), presses the Back button a couple of times and tries to add something to the shopping cart, it's an illegal command for that state and I can deal with it gracefully.

Where's the catch?

Design patterns are simply narrative and diagrammatic concepts that are programming language agnostic. The biggest challenge when using design patterns is finding a description pertinent to the type of problem you're trying to solve that has examples in the programming language you're using. Design Patterns by Erich Gamma et al, was written during the client-server era, and therefore describes pattern use in client-server concepts for applications with a GUI front-end written in C++. However, for folks working with the WebSphere platform the challenge is to understand how patterns apply to Web applications and how to implement patterns in Java.

Over the last year, I've done considerable research into this and have built frameworks around pattern implementations that I've found tremendously valuable. Some of the patterns I've used are Factory Method, Singleton, Command, State, and Façade. Look for articles on how to implement these patterns in upcoming issues of WebSphere Advisor, but also vow to become a student of patterns.

In the spirit of discovering and sharing best practices, the August 2001 issue of WebSphere Advisor offers articles to help you develop and deploy more efficient and secure EJB-based applications. Dennis Pagano's article on page 22 covers the design and development phases, and Bob Balaban's article on page 30 shows how to make sure EJBs are secure before you deploy them.

Foster Code Reuse Via Design Patterns

No reader comments ... yet.

    What do YOU think about this topic? Share your advice and thoughts using this form.

    Your Name

    REQUIRED : PUBLIC

    Your E-Mail

    REQUIRED : PRIVATE

    Job, Company

    OPTIONAL : PUBLIC

    City, State, Country

    OPTIONAL : PUBLIC

    Your Web Site

    OPTIONAL : PUBLIC

    Your Comment

    Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


    Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

    Tony HighamTony Highham is chief solutions officer for FatWire Software, and a technical editor of WebSphere Advisor. Tony has worked in the IT industry since 1979 and specializes in the design and delivery of enterprise-wide e-business solutions. He has been the architect and lead-developer of numerous e-business solutions, and gained deep insight into Lotus and IBM technologies during his three-year tenure with Lotus, and is presently focusing on Java and IBM technologies. As a die-hard programmer, and a believer in "practice what you preach," Tony's passion is breaking out the development tools and writing well-documented code to prove that technologies can be used in a practical manner. http://www.fatwire.com

    Printer-friendly
    page layout

    Keyword Tags: Application Development, Code, Component-Based Development (CBD), Enterprise Java Beans (EJB), IBM, IBM WebSphere, IT Profession, Java, OOP (Object-Oriented Programming), Software Development, Web Development

    ARTICLE INFO

    DataBased.Advisor.com

    Print Edition: August 2001, Page 10

    FREE ACCESS FREE ACCESS

    Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
    Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
    Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
    ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
    Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
    Hosted by Prominic.NET Website powered by
    LOTUS SOFTWARE
    HIGHT15 posted 08/01/2001 modified 07/01/2009 03:09:04 AM ztdbms/ztdbms
    domino-144.advisor.com my.advisor.com 07/04/2009 08:20:49 PM