Welcome!

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).

    Summary
    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.

    Resources

  • 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.


    @ThingsExpo Stories
    Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
    The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
    "Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
    A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
    Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. 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 ov...
    Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
    SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
    SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
    To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
    "Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
    No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...