Title: Toward Effective Deployment of Design Patterns for Software Extension A Case Study
1Toward Effective Deployment of Design Patterns
for Software Extension A Case Study
- T.H. Ng1, S.C. Cheung2, W.K. Chan2, and Y.T. Yu1
- 1Department of Computer Science, City University
of Hong Kong - 2Department of Computer Science and Engineering,
Hong Kong University of Science and Technology
ICSE-WoSQ06, May 21 2006
2Outline
- Introduction
- Case Study
- Related Work
- Empirical Experimentation
- Conclusion
3Introduction
- Design patterns by Gamma et al. 8
- Proven solutions to recurring problems 5
- Common belief
- Using design patterns leads to extensible
software. Is that conjecture legitimate?
5 M.P. Cline, The Pros and Cons of Adopting
and Applying Design Patterns in the Real
World, Comm. ACM, Vol. 39, No. 10, October
1996, pp. 47-49.
8 E. Gamma, R. Helm, R. Johnson, and J.
Vlissides, Design Patterns Elements of
Reusable Object-Oriented Software.
Addison-Wesley, 1995.
4Challenge
- Difficulty of validating the conjecture
- Requires an objective measurement of
extensibility, which is still an open
controversial concept
5Our Approach
- Goal
- Whether this is any relationship between the
pattern theme and the Open-Closed principle - Pattern theme
- Common ideas of patterns
- Open-Closed principle 13
- Advocated by many to achieve extensible software
13 B. Meyer, Object-Oriented Software
Construction. Prentice Hall, 1988.
6Proposed Scheme
- Two phases
- Mark code fragments as reusable or changeable
- Check structural conformance to the Open-Closed
principle
7Pattern Theme
- A pattern requires all changeable code fragments
to be encapsulated in specified design modules,
such as concrete subclasses in an inheritance
hierarchy
8Open-Closed Principle
- The Principle
- Software entities should be open for extension,
but closed for modification 23 - Conformance to the principle
- Changeable code fragments are in distinct
partitions from the reusable ones
23 B. Meyer, Object-Oriented Software
Construction. Prentice Hall, 1988.
9Outline
- Introduction
- Case Study
- Related Work
- Empirical Experimentation
- Conclusion
10Case Study
- Multi-user Calendar Manager (MCM)
- Functionalities
- Appointment Scheduling
- Display excessive verbose information for error
reporting. Three verbose modes are supported
Null, Exception, and Debug - Anticipation of new verbose modes in the future
- Deployment of the State pattern
- Goal To prepare for supporting new verbose modes
later
11Case Study
Figure 1 State pattern deployment in MCM (in UML
notation)
12An Undesirable Scenario
Specific to Debug verbose mode
Specific to Debug verbose mode
Specific to Debug verbose mode
Specific to Exception verbose mode
Figure 2 A client procedure that uses both the
State pattern and some unclean statements
(S1-S4)
13A Undesirable Scenario
- Reusable and changeable statements for the
support of new verbose modes - Each statement specific to an existing verbose
mode, such as S1, S2, S3, and S4, is changeable. - Each statement not specific to any existing
verbose mode is reusable - Violation of Open-Closed Principle
- The implementation of the operation in Figure 2
comprises both reusable and changeable statements
for future support of new verbose modes
14Outline
- Introduction
- Case Study
- Related Work
- Empirical Experimentation
- Conclusion
15Related Work
- Structural and behavioral conformance 720
- Our case study
- Structural and behavioral conformance is
satisfied - The Open-Closed principle is violated
7 R.B. France, D.K. Kim, S. Ghosh, and E. Song,
A UML-Based Pattern Specification Technique,
IEEE Trans. Software Eng., Vol 30, No. 3, 2004,
pp. 193-206..
20 N. Soundarajan, and J.O. Hallstrom,
Responsibilities and Rewards Specifying Design
Patterns, ICSE 2004, Edinburgh, pp. 666-675.
16Outline
- Introduction
- Case Study
- Related Work
- Empirical Experimentation
- Conclusion
17Empirical Study
- Null Hypotheses
- When the pattern theme is not satisfied, there is
at least a 20 chance where open-closed
conformance is followed in a pattern-based
program - When the pattern theme is satisfied, there is at
least a 20 chance where open-closed conformance
is violated in a pattern-based program
18Empirical Study
- Controlled Experiment
- 98 subjects individually developing the MCM
program - Materials
- Program requirements
- Functional correctness
- The deployment of the State pattern
- The satisfaction of the pattern theme
- Issues
- Subjects are unaware of the Open-Closed principle
19Empirical Study Results
40 (40.82) Population satisfying the theme of
patterns
43 (43.88) Population establishing conformance
to the Open-Closed Principle
98 (100) Total population, all deployed the
State patterns as the design in Figure 1
20Rejecting Hypothesis (a)
- Violating the pattern theme likely leads to the
violation of conformance to the Open-Closed
principle
40 (40.82) Population satisfying the theme of
patterns
43 (43.88) Population establishing conformance
to the Open-Closed Principle
Only 3 cases where the Open-Closed principle is
followed when the pattern theme is violated
98 (100) Total population, all deployed the
State patterns as the design in Figure 1
21?2 Test on the Hypothesis
- a denotes whether the Open-Closed principle is
achieved - i denotes the random variable the condition of
a - Oi denotes the observed frequency Ei denotes
the expected frequency, as implied by the
hypothesis with a 20 chance of achieving
open-closed conformance when the proposed
criterion for deployed patterns is not satisfied.
- Please be informed that there are 40
participants satisfying the pattern theme so the
total observed frequencies are therefore 58
(98-40).
22Rejecting Hypothesis (b)
- Satisfying the pattern theme leads to conformance
to the Open-Closed principle
40 (40.82) Population satisfying the theme of
patterns
43 (43.88) Population establishing conformance
to the Open-Closed Principle
98 (100) Total population, all deployed the
State patterns as the design in Figure 1
23Outline
- Introduction
- Case Study
- Related Work
- Empirical Experimentation
- Conclusion
24Conclusion
- Summary
- Research Question
- Using design patterns leads to extensible
software. Is this conjecture legitimate? - Experimental results
- Yes, if the pattern theme is satisfied.
- Satisfying the pattern theme is a sufficient and
close to necessary condition to follow the
Open-Closed principle - Future work
- Automate checking of pattern theme
- Study other forces and tradeoffs influencing the
software design of extensible software
25Questions and Answers