A quantitative approach for evaluating
the quality of design patterns
Nieh-Lin Hsheh, Peng-Hua Chu, William Chu
The Journal of Systems and Software 81 (2008)
1430 – 1439
M9837205 鄭聰賢
Introduction (1/2)
 Object-oriented is a paradigm of the
software engineering now.
 Design pattern
 based on object-oriented.
 is to define an abstraction of problem.
 is to solve this particular problem.
 But how to know a design pattern is good?
How to define “good”?
Introduction (2/2)
 So, what we need?
 An evaluation approach to help pattern
developers check if a design pattern is well-
designed.
 A quantitative method that help measure the
effectiveness of the quality improvement of a
design pattern.
QMOOD
Quality Model for Object-Oriented Design
(Bansiya and Davis, 2002)
Essentials of design pattern
 There are four essentials of design pattern
(Gamma et al. 1994)
 Pattern Name
 Intent
 Solution
 Consequences
Pattern evaluation (1/2)
Observer pattern
Define an one-to-many dependency between
objects so that when one object changes state, all
its dependents are automatically notified and
undated. (Gamma et al. 1994)
Functional aspect
The subject to notify all observers
when it changes its state.
Non-functional aspect
Notification to work automatically
without knowing the types of
observers.
FR-intent (IF)
NFR-intent (IN)
Quality focus Q(dp) = (IF , IN)
Pattern evaluation (2/2)
FR-structure NFR-structure
SF(dp) SN(dp)
T
)()(),( dpSSTdpS NFS 
COF (COupling Factor)
 The coupling factor (Brito and Abreu, 1995)
 
TCTC
CCclientis
TC
i
TC
j ji

  
2
1 1
),(_
where TC is the total number of classes and
Quality improvement effectiveness
 )(
)())((
),( m
mmT
MmGTM 

 

μ : an object-oriented metric
M: meta-model
T: transformation
G: an aggregation function* such as an average function
: a typical model set whose elements are instantiated from M
m: any instances of M
T(m): total classes that transformed
* In computer science, an aggregate function is a
function that returns a single value from a
collection of input values such as a set, a bag or
a list. See: http://goo.gl/RrKkJ
M
μ (M,T) > 0 means that the transformation T enhances the property
P, i.e., T can transform instances of M into another model with a
higher property P.
μ (M,T) < 0 means the transformation T impairs the property P
μ (M,T) = 0 means the transformation T is effectiveless on the
meta-model M
Quality Improvement Effectiveness
on property P
Assume a design TSSCPIIdp NFNF ,,,,,, C: Coupling Factor
P-improver
)),(()()(*
satisfiedSIddpimproverPdpimproverP FF 
Define: a design pattern dp is a well-designed P-improver
if it is a P-improver and its NFR-structure does not impair
its FR-intent, i.e.,
where d(intent, structure) is a satisfaction function, representing the
degree to which the intent can be realized in the structure.
•The degree is called satisfaction degree in our approach.
•If the intent is a functional intent, the degree is either 1 (satisfied) or 0
(not satisfied).
•If the intent is nonfunctional, the degree ranges between 0 and 1.
•The satisfaction degree is just a concept which cannot be directly
measured.
Case Study - Mediator (1/3)
Mediator pattern:
 Define an object that encapsulates how a set
of object interacts. Mediator promotes loose
coupling by keeping objects from referring to
each other explicitly, and it lets you vary their
interaction independently. (France et al. 2004)
Case Study - Mediator (2/3)
 Step 1: Extraction the nonfunctional intent
and the quality focus definition
 IF(Mediator) : A colleague object can
communicate with other colleague objects.
 IN(Mediator) : A colleague object can
communicate with other colleague objects in a
loose coupling manner by explicitly keeping
objects from referring to each other.
Step 2: Designing the
pattern structures
Step 3: Designing the
transformation
Case Study - Mediator (3/3)
QIEP(Mediator) = -0.7195 ≒ -0.72 is negative,
consistent with the constraint “decreased” coupling factor,
so we conclude the Mediator is a Coupling-Improver.
Step 4. Performing pattern validation
Conclusion
 A quality-improver design pattern is a design pattern
which intents to address quality requirements and
has a better structure for addressing them.
 In the future, we plan to develop a tool for our
verification method. A XMI-based representation will
be developed for representing the meta-level
functional and non-functional structures of a design
pattern.
 To define the transformation in the design pattern,
we will explore the possibility of applying the
technique of Model-Driven Architecture (MDA)

Quality of design patterns

  • 1.
    A quantitative approachfor evaluating the quality of design patterns Nieh-Lin Hsheh, Peng-Hua Chu, William Chu The Journal of Systems and Software 81 (2008) 1430 – 1439 M9837205 鄭聰賢
  • 2.
    Introduction (1/2)  Object-orientedis a paradigm of the software engineering now.  Design pattern  based on object-oriented.  is to define an abstraction of problem.  is to solve this particular problem.  But how to know a design pattern is good? How to define “good”?
  • 3.
    Introduction (2/2)  So,what we need?  An evaluation approach to help pattern developers check if a design pattern is well- designed.  A quantitative method that help measure the effectiveness of the quality improvement of a design pattern.
  • 4.
    QMOOD Quality Model forObject-Oriented Design (Bansiya and Davis, 2002)
  • 5.
    Essentials of designpattern  There are four essentials of design pattern (Gamma et al. 1994)  Pattern Name  Intent  Solution  Consequences
  • 6.
    Pattern evaluation (1/2) Observerpattern Define an one-to-many dependency between objects so that when one object changes state, all its dependents are automatically notified and undated. (Gamma et al. 1994) Functional aspect The subject to notify all observers when it changes its state. Non-functional aspect Notification to work automatically without knowing the types of observers. FR-intent (IF) NFR-intent (IN) Quality focus Q(dp) = (IF , IN)
  • 7.
    Pattern evaluation (2/2) FR-structureNFR-structure SF(dp) SN(dp) T )()(),( dpSSTdpS NFS 
  • 8.
    COF (COupling Factor) The coupling factor (Brito and Abreu, 1995)   TCTC CCclientis TC i TC j ji     2 1 1 ),(_ where TC is the total number of classes and
  • 9.
    Quality improvement effectiveness )( )())(( ),( m mmT MmGTM      μ : an object-oriented metric M: meta-model T: transformation G: an aggregation function* such as an average function : a typical model set whose elements are instantiated from M m: any instances of M T(m): total classes that transformed * In computer science, an aggregate function is a function that returns a single value from a collection of input values such as a set, a bag or a list. See: http://goo.gl/RrKkJ M μ (M,T) > 0 means that the transformation T enhances the property P, i.e., T can transform instances of M into another model with a higher property P. μ (M,T) < 0 means the transformation T impairs the property P μ (M,T) = 0 means the transformation T is effectiveless on the meta-model M
  • 10.
    Quality Improvement Effectiveness onproperty P Assume a design TSSCPIIdp NFNF ,,,,,, C: Coupling Factor
  • 11.
    P-improver )),(()()(* satisfiedSIddpimproverPdpimproverP FF  Define:a design pattern dp is a well-designed P-improver if it is a P-improver and its NFR-structure does not impair its FR-intent, i.e., where d(intent, structure) is a satisfaction function, representing the degree to which the intent can be realized in the structure. •The degree is called satisfaction degree in our approach. •If the intent is a functional intent, the degree is either 1 (satisfied) or 0 (not satisfied). •If the intent is nonfunctional, the degree ranges between 0 and 1. •The satisfaction degree is just a concept which cannot be directly measured.
  • 12.
    Case Study -Mediator (1/3) Mediator pattern:  Define an object that encapsulates how a set of object interacts. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. (France et al. 2004)
  • 13.
    Case Study -Mediator (2/3)  Step 1: Extraction the nonfunctional intent and the quality focus definition  IF(Mediator) : A colleague object can communicate with other colleague objects.  IN(Mediator) : A colleague object can communicate with other colleague objects in a loose coupling manner by explicitly keeping objects from referring to each other.
  • 14.
    Step 2: Designingthe pattern structures Step 3: Designing the transformation
  • 15.
    Case Study -Mediator (3/3) QIEP(Mediator) = -0.7195 ≒ -0.72 is negative, consistent with the constraint “decreased” coupling factor, so we conclude the Mediator is a Coupling-Improver. Step 4. Performing pattern validation
  • 16.
    Conclusion  A quality-improverdesign pattern is a design pattern which intents to address quality requirements and has a better structure for addressing them.  In the future, we plan to develop a tool for our verification method. A XMI-based representation will be developed for representing the meta-level functional and non-functional structures of a design pattern.  To define the transformation in the design pattern, we will explore the possibility of applying the technique of Model-Driven Architecture (MDA)

Editor's Notes

  • #7 Observer pattern如何
  • #8 The property refers to an object-oriented design property defined in U2, which may be design size, hierarchy, abstraction, encapsulation, coupling, cohesion, composition, inheritance, polymorphism, message, or complexity. Constraint refers to the expected constraint on the subject’s property, which may be increased, decreased or maintained.
  • #10 如何能夠宣稱,當套用某個design pattern時對原本的model是有效的?
  • #11 簡單來說:要看某個功能性結構,套用了某個dp後,是否在某個屬性(P)上有所影響,那麼可套用這個公式進行測量,若QIEp大於0,則可宣稱某個因子,例如 Coupling是增加的