Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Practical Adoption of Design Patterns

Practical Adoption of Design Patterns

Often there is a distinction between concepts and how those concepts are applied in the real world. Design patterns are no exception.

Design patterns are everywhere. It's hard to read a technology publication or Web site without seeing some reference to design patterns. By now you have probably read (or at least paged through) some of the design pattern books, such as Core J2EE Design Patterns or Design Patterns by the Gang of Four. At this point you are possibly asking some questions about design patterns. How will design patterns help me? Are they a silver bullet? Are there any problems with design patterns? Don't I get design patterns from my integrated development environment (IDE)?

All of these are good questions to ask as you go through the process of adopting design patterns. Often there is a distinction between concepts and how those concepts are applied in the real world. Design patterns are no exception. In this article we'll look at the real world adoption of design patterns. This information should help you make the right decisions about successfully adopting design patterns in your project.

Quick Overview
Design patterns provide a way to share experiences so that a community can benefit and not continually reinvent the wheel. Design patterns typically capture a problem description, the context of the problem, a proposed solution to the problem, and any anticipated consequences of using the solution. In order to have the broadest applicability (and therefore usefulness to the largest audience), design patterns are often abstracted from exact details that are situation dependent. This abstractness results in some required interpretation to apply the design pattern to the case at hand. This is an important detail: even though design patterns are a great way to share expertise, it is often not trivial to correctly apply that expertise.

The concept of design patterns originated in the construction industry. Architects (the ones that design buildings, not computer systems) realized they needed to share ideas about correct design techniques. These ideas were captured in design patterns that allowed the architect community to benefit from shared experiences and lessons learned. Design patterns made the leap from construction to computer systems in the late '80s. Object-oriented (OO) philosophies were gaining popularity and design patterns were a way to educate the new OO followers on best practices.

The book that launched design patterns into the limelight is Design Patterns: Elements of Reusable Object-Oriented Software by Richard Gamma, et al (the authors are commonly referred to as the Gang of Four [GoF]). As design patterns have grown in popularity, the number of flavors they come in has also ballooned in what could be described as the "Ben and Jerry" effect. For those of you not familiar with the popular ice cream brand, Ben and Jerry's is a purveyor of fine ice cream products that come in every imaginable combination of ingredients (including some you would never have ever imagined). So it is with design patterns, which originated with the general OO design patterns from the GoF book but now include design patterns that are specific for development languages, application servers, industry verticals, and so on.

Categorizing Design Patterns
Design patterns are often grouped together based on some common characteristics. The GoF book divided design patterns into three categories: Creational, Behavioral, and Structural. Design patterns for J2EE are often divided into Presentation Tier, Business Logic Tier, and Integration Tier. This grouping may make it easier to describe common details that all the design patterns share or simply make it easier to catalog and discover design patterns.

For our discussion of the practical adoption of design patterns, we need to divide design patterns into two categories: broad exposure and isolated use. This division is based on the visibility of the design pattern to the designers and developers of the application and the dependency of multiple parts of the application on the design pattern.

Broad exposure design patterns are distinguished by affecting the designs and development of more than just one team member or more than one area of the application. Some qualities of this type of design pattern are:

  • Adopting it has the downstream effect of many classes being created that depend on the design pattern.
  • Different parts of the application are aware of the use of the design pattern.
  • The decision to use this design pattern cannot be easily undone.

    Some examples of this type of design pattern are the Model-View-Controller (MVC) pattern, the Value Object J2EE pattern, and the Data Access Object (DAO) J2EE pattern.

    Isolated use refers to design patterns for which the use of the design pattern is a hidden detail. Some qualities of this type of design pattern are:

  • The design pattern does not impact the work of other team members or other parts of the application.
  • The decision to use the design pattern could easily be changed with minimal impact.

    Some examples of this type of design pattern are the Singleton GoF pattern or the Intercepting Filter J2EE pattern.

    Dividing design patterns into these categories provides a quick approach for understanding the scope of the design pattern. Understanding scope makes it easy to assess the impact of the design pattern. Is it a design pattern that can be used and discarded? Is it a design pattern that once adopted will impact the design of the application? Is it a design pattern that affects multiple parts of my application and possibly other applications? Understanding these impacts up front provides guidance for adopting the design pattern.

    Design Pattern Adoption AntiPatterns
    As design patterns grew in popularity, another type of patterns emerged called AntiPatterns. Whereas design patterns offer expert knowledge on repeatable best approaches, AntiPatterns describe often repeated behavior that should be avoided. AntiPatterns prove there is as much to be learned from people who do things wrong as those who do things right.

    In this section, we'll look at AntiPatterns that apply to the adoption of design patterns. Understanding these AntiPatterns should help you avoid the pitfalls of design pattern adoption. Like design patterns, the AntiPatterns here may be entirely new to you, in which case they provide some foresight; or they may be situations you are somewhat familiar with, in which case they can add color to your experiences and let you know that you're not alone. If you are interested in reading more AntiPatterns, see the resource list at the end of this article.

    AntiPattern Checklist
    Design Patterns? Yes, We Have All of Them

    Problem: Determining which design patterns to include on a project.

    Applies To: Both broad exposure and isolated use design patterns.

    Context: A developer has been introduced to design patterns and wants to use them on a project.

    Forces: Two forces are usually the source for this AntiPattern. One is the desire of the developer to improve the project by including best practices from design patterns. The other is that innate curiosity drives the developer to use the project for research on design patterns.

    Supposed Solution: All known design patterns are used on the project. A checklist is formed from the design pattern book and the motivating goal is to be able to check off all of the design patterns.

    Resulting Context: The project team and the delivered application suffer from the unnatural introduction of too many design patterns. This results in designs and development that are overly complex. This unnecessary complexity can impact the development effort in terms of the amount of work that has to be done, the ability of the development team to understand what is happening, and the actual performance and functional correctness of the application.

    Design Rationale: Design patterns are a great source of expert knowledge. If using them is good, then using all of them is mistakenly thought of as better.

    Real Solution: The description of a design pattern includes the context for which the pattern is targeted. Thought must be given to ensure that the design pattern is a match for the project. Second, design patterns are often incorporated not from someone reading a design pattern book and asking "where can I use this design pattern?" but from someone looking for a solution to a problem they have discovered.

    Implementation per Developer/Project AntiPattern
    (Also known as: Design pattern xyz? Yeah, we have 10 of those.)

    Problem: Controlling the implementation of design patterns within a project and across projects.

    Applies To: Both broad exposure and isolated use design patterns benefit from addressing this situation. However, broad exposure design patterns should definitely have controlled implementations.

    Context: The development team is incorporating design patterns into the project. The team consists of many experienced developers who understand when to use design patterns. The correct design patterns are being used. If multiple projects are involved, there is no design pattern - implementation sharing between projects.

    Forces: There are tight deadlines and the team is very efficient individually. Team efficiency might be impacted if they have to reuse implementations. It is assumed that since they are experts, their implementation will be good anyway. In the case of multiple projects, the cross-team communication and code sharing either is not considered or is dismissed as a potential impact on schedules.

    Supposed Solution: The team can include and implement the design patterns they need as individuals.

    Resulting Context: Even though the correct design patterns were used, they were implemented in many different ways. There are incompatibilities between the implementations that restrict integration and reuse efforts. More time and effort than necessary will have to be spent maintaining, debugging, and extending the various implementations. Eventually the various implementations will have to be consolidated.

    Design Rationale: A team of experts should be allowed to work alone. Including design patterns is good enough, there is no reason to share implementations.

    Real Solution: The development team should coordinate their use of design patterns. Sharing a common implementation of a design pattern can lower costs in the future, but more important, it should result in cross-developer compatibility today. If necessary, this sharing could be limited to design patterns that fall into the broad exposure category we discussed earlier. Reusing implementations is also valuable across projects, especially if they are expected to integrate in the future.

    Role of IDEs in Design Pattern Adoption
    IDEs continue to evolve and offer more functionality. Originally IDEs consisted of an editing environment and some debugging facilities. Now they often include a design environment, auditing facilities, integration with configuration management systems, and more. As IDEs expand their reach, their role in implementing design patterns needs to be identified. Of course, design patterns are implemented in a development language and IDEs can be used for editing the source code. But what other roles can IDEs play?

    Some IDEs have pull-down menus that allow you to select design patterns to include in your application. While this can expedite the inclusion of a design pattern, it might just result in writing bad code faster. There are a couple of factors to remember in evaluating this feature.

    One is that design patterns describe problems in the abstract and require some interpretation to arrive at the correct implementation. However, they often include a "sample implementation" and it is this sample class structure that the IDEs insert into your application. This is probably not the implementation that you need and just dropping it into your application will introduce more confusion and require more editing and refactoring than just putting thought into your own original implementation.

    Another problem with the IDE drag-and-drop design pattern approach is the two AntiPatterns we already discussed. Expediting the implementation of design patterns is more likely to result in rampant inclusion of design patterns and multiple versions of the same design pattern than it is to solve any problems.

    The challenge with design patterns isn't just in getting a quick implementation, but making sure you are using a correct implementation, and ideally an implementation that already exists in your organization.

    BEA WebLogic Workshop 8.1 and Design Patterns
    Since you are probably a BEA customer if you are reading this article, you may be wondering how the new BEA WebLogic Workshop 8.1 impacts your design pattern considerations. First of all, WebLogic Workshop is an IDE so the previous section on IDEs applies. The two additional aspects of Workshop that are interesting for this discussion are Controls and pre-implemented design patterns.

    WebLogic Workshop Controls are a way to package functionality so that it can be easily included in your application using the Workshop IDE. The packaging includes the visual elements required for the IDE, the runtime behavior, the configuration required, and more. How do Controls impact your inclusion of design patterns? Remember the earlier segregation of design patterns into isolated use and broad exposure? Design patterns that fall into the isolated use category may be candidates to be packaged as Workshop Controls. Packaging the design pattern as a Control would allow other users of the Workshop IDE to share an implementation, avoiding the Implementation per Developer/Project AntiPattern.

    You may be wondering why the broad exposure category cannot be implemented as Controls. The reason is that the broad exposure design patterns result in the creation of many other classes or in some dependence with other applications. This situation does not lend itself to the plug-and-play aspect of Controls. Adoption of the broad exposure design patterns should be done with much thought and consideration, and once adopted cannot be undone easily. These requirements do not match with the WebLogic Workshop Control goals.

    WebLogic Workshop also comes with many pre-implemented design patterns, such as Pageflow and the user interface structure. From within Workshop, you can create JSPs and define Pageflows to control the navigation between the pages of your Web application. Under the hood, WebLogic Workshop uses the popular Apache Struts presentation layer framework. This aspect of Workshop (which uses Struts) provides a Model-View-Controller (MVC) design pattern implementation, which means you won't have to create your own MVC implementation. Workshop includes other functionality that will probably replace your own design pattern implementations. While it is nice to get some of these design patterns implemented out-of-the-box, you should validate that you are comfortable with not only the implementation but with any dependency on WebLogic Workshop that the implementation creates.

    Three Steps for Successful Design Pattern Adoption
    So how do you merge the adoption of design patterns with the tight deadlines, scaled back budgets, and limited team resources that exist in many companies today? The following are three steps to follow to make your design pattern experience successful.

    Strong Communication and Education
    Many organizations have technical leadership, possibly formalized as an architects forum or informally as the recognized experts. These leaders should promote open communication around design pattern adoption and should educate the teams about specific design patterns. The communication should be across development teams and projects to proactively prevent adoption silos and multiple unique implementations (remember the Implementation per Developer/Project AntiPattern). The education can take the form of informal internal lunch-and-learns, formalized internal classes, or maybe even sending a few people to external training. Any of these education options should promote correct applications of design patterns. If only a limited audience can attend the training, the best candidates are ones who feel comfortable educating their peers upon return.

    Mentored Design Pattern Adoption
    Design patterns can be used for the benefit of the project but they are also easy to misuse to the detriment of the application. Their use should be encouraged but their adoption should be reviewed and verified. Design patterns can be included during both design and development. In either case, design patterns' use should be identified and verified by the reviewer. Also during this review, situations may be encountered where additional design patterns may be applicable that weren't originally included. Even if official reviews are not done in your environment, this step could be accomplished through peer reviews or team discussions. The reviewers in this step should be either part of the leadership team or in open communication with them.

    Mentoring adoption is especially critical for the broad exposure category of design patterns. These are the design patterns that have more associated risk because they will create dependencies. These dependencies may be within a class of objects, such as data access objects (DAOs) that only work within the scope of a broader DAO design pattern implementation, or across application boundaries, such as use of the Value Object design pattern to communicate data between applications and application layers. These design patterns are also ones that may have been implemented by somebody else on the project or by a different project, and that implementation should be reused versus creating another unique implementation.

    Reuse Implementations, Not Just Design Patterns
    While there is a certain satisfaction that comes in creating your own implementation of a design pattern, there is more benefit to the team and company when reuse takes place at the code level and not just the design idea level. The initial benefit design patterns provide to an organization is improved implementations. The real goal, however, should be to reuse implementations. Reusing implementations will result in: a) other reusable classes (that depend on the common implementation); b) lower development time and costs; c) lower maintenance time and costs; and d) easier integration both within and between applications.

    This reuse is more important (and sometimes essential) for the broad exposure category. These design patterns are the ones that create external dependencies (where integration would benefit from a common implementation) or result in a whole library of custom classes (that would be reusable if there was a common foundation). The isolated use category would benefit from reuse but they might be more difficult to reuse if they were strongly customized to their specific situation.

    Something you may ask yourself is, "If reuse is better, why don't design patterns come with a reusable implementation?" We touched on this when we talked about how design patterns are provided for the benefit of the largest audience. Achieving this goal of broad applicability would be difficult, if not impossible, if it came with a predetermined implementation. However, once the design patterns are applied to a particular problem domain or technical infrastructure, the resulting implementation may be reusable within that environment.

    Design Patterns Through Architecture
    It may seem a daunting task to understand how design patterns apply to your situation, build a quality implementation, and then encourage the reuse of that implementation. One approach to this is the introduction of application architecture into your environment. Application architecture provides the structure required for your application so that the development team can focus on the domain logic of the application. This includes implemented design patterns. Instead of reusing design pattern concepts or individual implementations, the architecture can be reused across projects and applications. This shared common implementation ensures compatibility and provides a lower cost alternative to developing and maintaining many different implementations. The compatibility provides the required technical foundation for reuse efforts to be possible. There is not enough space here to go into the other valuable qualities of architecture, such as runtime monitoring and management, configurable application logic, and adaptable behavior. You can learn more about architecture from the Carnegie Mellon Software Engineering Institute (www.sei.cmu.edu/ata/ata_init.html).

    Design patterns are an amazing resource that should be used to your advantage. While design patterns provide reusable concepts, the challenges come in determining which design patterns to use and working towards a reusable implementation. By understanding some of the risks involved with design pattern adoption, you can hopefully avoid them as you continue to learn and implement more design patterns.

    Following the steps outlined in this article will put a process in place that can be used to promote the successful adoption of design patterns on your team and within your organization.


  • Brown, William J.; Malveau, Raphael C.; McCormick, Hays W. "Skip"; Mowbray, Thomas J. (1998). AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis. John Wiley & Sons
  • AntiPatterns: www.antipatterns.com
  • Wiki site: http://c2.com/cgi/wiki?AntiPattern
  • More Stories By Walter Hurst

    Walter Hurst, Founder & CTO
    Walter Hurst has been working with advanced technologies for over ten years. Before founding Wakesoft, Walter was an independent consultant where he used early versions of Wakesoft technology to deliver Internet solutions to clients. Previously, Walter was a Technical Architect at Xpedior where he led internal efforts to develop application architectures that were implemented across client projects. Before Xpedior, Walter was a Senior Consultant at Andersen Consulting – Center for Strategic Technology. At Andersen, Walter led Enterprise projects for various Fortune 100 clients. Walter received a B.S. in Computer Engineering from the University of Michigan.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

    IoT & Smart Cities Stories
    The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get tailored market studies; and more.
    As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility. As they do so, IT professionals are also embr...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    Atmosera delivers modern cloud services that maximize the advantages of cloud-based infrastructures. Offering private, hybrid, and public cloud solutions, Atmosera works closely with customers to engineer, deploy, and operate cloud architectures with advanced services that deliver strategic business outcomes. Atmosera's expertise simplifies the process of cloud transformation and our 20+ years of experience managing complex IT environments provides our customers with the confidence and trust tha...
    AI and machine learning disruption for Enterprises started happening in the areas such as IT operations management (ITOPs) and Cloud management and SaaS apps. In 2019 CIOs will see disruptive solutions for Cloud & Devops, AI/ML driven IT Ops and Cloud Ops. Customers want AI-driven multi-cloud operations for monitoring, detection, prevention of disruptions. Disruptions cause revenue loss, unhappy users, impacts brand reputation etc.
    As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility.
    Today's workforce is trading their cubicles and corporate desktops in favor of an any-location, any-device work style. And as digital natives make up more and more of the modern workforce, the appetite for user-friendly, cloud-based services grows. The center of work is shifting to the user and to the cloud. But managing a proliferation of SaaS, web, and mobile apps running on any number of clouds and devices is unwieldy and increases security risks. Steve Wilson, Citrix Vice President of Cloud,...
    When Enterprises started adopting Hadoop-based Big Data environments over the last ten years, they were mainly on-premise deployments. Organizations would spin up and manage large Hadoop clusters, where they would funnel exabytes or petabytes of unstructured data.However, over the last few years the economics of maintaining this enormous infrastructure compared with the elastic scalability of viable cloud options has changed this equation. The growth of cloud storage, cloud-managed big data e...
    Artificial intelligence, machine learning, neural networks. We're in the midst of a wave of excitement around AI such as hasn't been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. This time is (mostly) different. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Pattern recognition can equal or exceed the ability of human experts in some domains. It's devel...