Skip to main content
Do Design Patterns Impact
  Software Quality Positively?


            Foutse Khomh and Yann-Gaël Guéhéneuc

                     foutsekh@iro.umontreal.ca, guehene@iro.umontreal.ca
                                             CSMR'08
GEODES Ptidej Team – OO Programs Quality Evaluation and Enhancement using Patterns
       Group of Open, Distributed Systems, Experimental Software Engineering
       Department of Informatics and Operations Research
       University of Montreal                                                        © Khomh, 2008
Context
        Design patterns (as presented by the GoF) have
        been said to have a positive impact on quality
        characteristics
        – Expandability
        – Reusability
        – Understandability


        But, some studies presented counter-examples, i.e.,
        Wendorff (Assessment of design patterns during
        software reengineering: Lessons learned from a large
        commercial project.)
2/??
Study Design (1/2)


        Hypothesis: “Design patterns have a
        positive impact on quality
        characteristics”

        Objective: prove or disprove the
        hypothesis with concrete evidence

3/??
Study Design (2/2)

        Required choices
        – Quality characteristics
        – Kind of study


        Our choices
        – 10 quality characteristics related to design,
          implementation, and runtime
        – Empirical study (vs. absolute, vs. relative)
           • Manual activity
           • Developers' perception
4/??
Method
        Choice of design patterns of interest
        – 23 design patterns in the GoF book


        Identification and definition of quality characteristics
        of interest
        – 10 characteristics
            Design          Implementation      Runtime
            Expandability   Learnability        Generality
            Simplicity      Understandability   Modularity at runtime
            Reusability     Modularity          Scalability
                                                Robustness

        Definition of a scale
5/??
        – Likert scale of 5 points + "I don't know"
Data Collection

         Questionnaire send out to colleagues
         with a good knowledge of design
         patterns between January and May
         2007

         Questionnaire posted on mailing-lists
          refactoring@yahoogroups.com
          patterns-discussion@cs.uiuc.edu
6/??
          gang-of-4-patterns@cs.uiuc.edu
Data Processing
        Number of received questionnaires: 30
        – Number of complete questionnaires: 18
        – Number of almost complete (90%) questionnaires: 2
        – Incomplete questionnaires or with “I don't know”:10


        Number of kept questionnaires: 20

        Answers A and B aggregated in Positive, C in
        Neutral, and D and E in Negative
        – Some questionnaire were clearly generally more
          positive/negative than others
7/??
Results (1/2)




8/??
Results (2/2)

         We discuss detailed results
         – Three well-known design patterns
           • Composite
           • Abstract Factory
           • Flyweight
         – Three quality characteristics mentioned in
           the GoF
           • Reusability
           • Expandability
9/??       • Understandability
Composite

                    Overall positive
                    impact on quality
                    attributes
                    Scalability and
                    robustness not so
                    positively impacted




10/??
Abstract Factory

                           Overall neutral
                           impact on quality
                           attributes
                           Expandability,
                           generality, and
                           modularity as
                           expected
                           Robustness
                           surprising
11/??
Flyweight

                    Overall negative
                    impact on quality
                    attributes
                    Positive impact
                    only on scalability
                    as expected




12/??
Reusability
           Positive     Neutral      Negative
        A.Factory     Builder     Bridge
                                                10 positive impacts
        F.Method      Singleton   Decorator
        Prototype     Facade      Flyweight     6 neutral impacts
        Adapter       Mediator    Command
        Composite
        Ch.Of.Resp.
                      Memento
                      Proxy
                                  Interpreter
                                  State
                                                7 negative impacts
        Iterator                  Visitor
        Observer
        Strategy
        T.Method




13/??
Expandability
           Positive     Neutral     Negative
        A.Factory     Flyweight   Singleton    19 positive impacts
        Builder       Memento
        F.Method      Proxy                    3 neutral impacts
        Prototype
        Adapter
        Bridge
                                               1 negative impact
        Composite
        Decorator
        Facade
        Ch.Of.Resp.
        Command
        Interpreter
        Iterator
        Mediator
        Observer
        State
        Strategy
        T.Method
        Visitor
14/??
Understandability
            Positive     Neutral      Negative
        A.Factory      Proxy       Decorator     15 positive impacts
        Builder        Memento     Flyweight
        F.Method       T.Method    Ch.Of.Resp.   3 neutral impacts
        Prototype                  Command
        Singleton
        Adapter
                                   Visitor       5 negative impacts
        Bridge
        Composite
        Facade
        Interpreter
        Iterator
        Mediator
        Observer
        State
        Strategy




15/??
Null Hypothesis Test




16/??
Conclusion (1/2)

         Globally, design patterns have a
         positive impact on quality attributes
          Quality                   Expandability        Simplicity     Reusabilit      Learnabilit     Understandabilit
          Characteristics                                               y               y               y

          Number of                 19+ / 4-             16+ / 7-       11+ / 12-       14+ / 9-        11+ / 12-
          Positive/Negative
          Patterns




          Quality Characteristics    Modularity     Generality        Mod. at runtime     Scalability     Robustness



          Number of                  18+ / 5-       19+ / 4-          11+/ 12-            1+ / 22-        0+ / 23-
          Positive/Negative
          Patterns

17/??
Conclusion (2/2)

         Pattern by pattern, their impact on
         quality varies and includes negative
         impact!

         So, design patterns do not always
         improve the quality of systems, thus
         they should be use with caution

18/??
Help Wanted

         Please help us refine this study by
         downloading and filling in the
         questionnaire



            http://www.ptidej.net/downloads/



19/??