Software Patterns for Reusable Design Robert S. Hanmer June, 2009
Jan 27, 2015
Software Patterns for Reusable Design
Robert S. Hanmer
June, 2009
2 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
About me
MSCS, Northwestern University, 1987.
Working at Northwestern University Med School & computer center benefited from shared software
While on AT&T 4ESS™ Switch project– learned about reusing design ideas and the importance of architectural integrity
In Bell Labs – shared my knowledge with projects
Now in Alcatel-Lucent Operations – making sure we only use good 3rd party and free software (FOSS)
Member of Alcatel-Lucent Technical Academy
Senior member of ACM
Writing patterns since 1994
President of Hillside Group
Author of Patterns for Fault Tolerant Software
Agenda
1. Design, Reusable & Software Patterns
2. What is a Software Pattern?
3. Pattern Communities
4. Using Patterns
5. Writing and Collecting Patterns
6. Pattern Research
7. Patterns within your community
8. Wrapup
Design, Reusable
& Software Patterns
5 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Design As a noun:
5 a: an underlying scheme that governs functioning, developing, or unfolding …b: a plan or protocol for carrying out or accomplishing something (as a
scientific experiment) ; also : the process of preparing this
As a verb:
1: to conceive or execute a plan2: to draw, lay out, or prepare a design
-- www.meriam-webster.com
6 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Reusable Adjective: capable of being used again or repeatedly
-- www.merriam-webster.com
Some adjectives that apply to things that are reusable:
flexible
Modular
understandable
-- Other fields have handbooks to capture their reusable information.
7 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Reusable Design Design and design elements that are
Modular
Flexible
Usable more than once
Can be communicated
Grady Booch: “Software development has been, is, and will likely remain fundamentally hard.”
8 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Software Patterns “The pattern is, in short, at the same time a thing, which happens in the world,
and the rule which tells us how to create that thing, and when we must create it. It is both a process and a thing; both a description of a thing which is alive, and a description of the process which will generate that thing.”
-- Christopher Alexander,The Timeless Way of Building
A software pattern is a description of modular proven solution to a design problem with enough information so that the reader can flexibly adapt it to their unique situations.
9 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
10 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
What is a Software Pattern?
11 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern: Leaky Bucket Counters
Context: A system that is intended to recognize and correct problems automatically. In this environment the system needs to know if a problem is something that comes and goes intermittently , or only happens once, i.e. is "transient" or is a repeating “permanent” fault that needs to be corrected. Signal crosstalk, static electric discharges, lightning strikes or intermittently broken keys on a keyboard cause transient errors, which should be treated differently than permanent faults.
Problem: How can you know if a fault is transient?
Forces: You want a module to exhibit a permanent error before taking drastic action. The component that reports the error might be an innocent victim. It shouldn’t be punished.
In many cases you are willing to allow a certain number of errors if they aren’t too close together. If they come too close together you want the system to trigger some sort of error processing action.
12 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Leaky Bucket Counters (2)
Solution: Each failure group that is to be watched has a counter (the leaky bucket counter) which is initialized to a predetermined value when the system is first initialized. The counter is incremented for each error or fault detected. The counter is decremented on a periodic timed basis, but will never be decremented beyond its initial value.
A counter incrementing past a pre-determined threshold value indicates that the rate of error or fault events exceeds the allowable rate (as defined by the empty or leak rate, rate of errors and threshold value). This should be taken as an indication that the fault is not transient.
13 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Leaky Bucket Counters (3)
Resulting Context: A system in which errors are isolated and handled (by taking devices out of service), but transient errors don't cause unnecessary loss of service.
Author: Robert Hanmer, incorporating several versions by Robert Gamoke, James Coplien and Gerard Meszaros. A revised version in a different format is in Patterns for Fault Tolerant Software.
14 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
What is a Pattern?
A proven solution
Rule of 3
More than an algorithm
A pattern explains the context when its applicable
A pattern explains the trade-offs and alternatives
“At the same time, a thing that happens in the world … and the rules to make that thing …”
15 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns Are:
A resolution of forces
A form of architectural and design documentation
Relationships that cuts across system parts
“Solution to a Problem in a Context”
A way of explaining non-traditional solutions
A family of solutions that abstractly address related problems in a specific context
A literary form
16 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns are useful for:
Learning from what has worked in the past
Not re-inventing the wheel
Not repeating past errors
Providing a vocabulary for architects/designers
Passing on architectural knowledge
Providing a window into the minds of the experts
Transferring proven solutions from one industry segment to another
To structure OO code
17 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns Will Not:
… make you an instant expert
… provide a “turn the crank” approach to software
… eliminate the need for intelligence and taste
… make you rich and famous
unless you become a snake oil salesman
… generate code
– Paul S. R. Chisholm, AT&T 10/94
18 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Depth of Patterns
Some patterns are at a very low-level:
An example solution: Use a shift to multiple or divide by a power of 2
Some are very general:
For example: Model View Controller
19 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
The Quality Without A Name
“There is a central quality which is the root criterion of life and spirit in a man, a town, a building, or a wilderness [or software]. This quality is objective and precise, but it cannot be named.”
– Alexander, The Timeless Way of Building
Who was Christopher Alexander?
Building architect and theorist, Professor at UC Berkeley www.patternlanguage.com
Many books on architecture and art:
Patterns: A Pattern Language, The Timeless Way of Building, The Oregon Experiment, The Production of Houses
Art: A Foreshadowing of 21st Century Art -- The Color and Geometry of Very Early Turkish Carpets
Beyond patterns: The Nature of Order
20 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns Handbook
Patterns build the handbook of software design and construction
Patterns available in reference book easily accessible to designers
No need to memorize all the details -- the reference book is available
21 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
The Pattern Almanac
Published 3/2000
Summarizes all the published,widely available patterns
Indices based upon pattern intent
Planned to be updated regularlyand to be available on the internet
22 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
What is a Pattern Language?
A collection of patterns that work together
A collection of patterns that build upon each other to build something bigger than any of the individual patterns can build
“All acts of building are governed by a pattern language of some sort.”
– TTWOB, p 193
23 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
An Example Pattern Language
Telecom IO
A specialized set of patterns for defining the human-machine interface has come into use with the world of embedded telecommunications products. These patterns provide an essential interface between a system and its human masters.
24 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Telecom IO Pattern Intents
Return output only to the logical channel/terminal that requested it.Who Asked?
Add a timestamp and/or a sequence number to each output message.Timestamp
Issue messages to summarize a number of events rather than for each of many events.
The Bottom Line
Provide a system to system emergency information channel.String A Wire
Give human input/output messages a high priority.Shut Up And Listen
Provide a way for recovery systems to bypass the IO Gatekeeper.Raw I/O
Provide for internal subsystems to add IO to the stream.Pseudo-IO
Allow the alarm system to be customizable with site specific alarms.Office Alarms
Use a standardized IO language.MML
Only send output to concerned terminal groups (logical channels).Mind Your Own Business
Add a priority tag to each output message and sort the output using them.IO Triage
Put one process in charge of IO for the system.IO Gatekeeper
Issue state change messages only when the state changes, not to remind about the current state.
George Washington is Still Dead
Don't confuse craft with too frequent messages.Five Minutes of No Escalation Messages
Reassert alarms when necessary, purposely forgetting requests to retire the alarms.
Don't Let Them Forget
Allow workers to take their terminals with them.Beltline Terminal
Sound audible alarms to alert office personnel of problems.Audible Alarms
Group alarms into grids to help the workers identify problems.Alarm Grid
25 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
PLoPD-4
Telecom IO
26 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
What is a Software Pattern?
A description of a reusable proven design element
with enough information to recreate the design, customized for the situation
An element of a pattern language
A collection of patterns that work together to solve larger problems
The building block for a software handbook
27 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Communities
28 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Communities
The Hillside Group
A worldwide organization to make the life of people touching software better and to sponsor pattern conferences. Hillside.net
Hillside Europe
A European group centered around Germany that sponsors conferences and SE Radio. hillside.net/europlop/HillsideEurope, se-radio.net
HCI pattern community
www.hcipatterns.org – Jan Borchers
www.welie.com – Martijn van Welie
29 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns Community
Pattern movement origins
1989-1992
Advanced C++ Programming Styles & Idioms by James Coplien
OOPSLA
Hillside Group
Pattern Conferences
PLoP
hillside.net/plop
EuroPLoP
hillside.net/europlop
SugarLoaf PLoP
VikingPLoP
ChiliPLoP
KoalaPLoP
Using Patterns (UP)
30 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
“Culture”
“5a: the integrated pattern of human knowledge, belief, and behavior that depends upon man's capacity for learning and transmitting knowledge to succeeding generations
“5b : the customary beliefs, social forms, and material traits of a religious, or social group
“5c : the set of shared attitudes, values, goals, and practices that characterizes a company or corporation”
– Merriam Webster Collegiate Dictionary on the web http://www.m-w.com/dictionary.htm
Shared experiences
Shared rituals
Writers’ Workshop
Shared values
31 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Writers’ Workshops
Good patterns are highly reviewed and refined.
Writers’ Workshop from the literature/poetry community are used to review patterns.
Structured discussion of the merits and suggestions for improvement.
Author is present for note taking but does not participate except at very specific times.
A strong moderator role to guide discussion.
Authors are expected to revise and improve their patterns.
32 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
After writing, workshopping and revising: publish
Patterns are meant to be read!
Conference proceedings
hillside.net/conferences points to proceedings of PLoP and EuroPLoP
EuroPLoP, SugarLoaf PLoP and VikingPLoP publish hard copy proceedings
PLoP and EuroPLoP publish proceedings in ACM Digital Library.
Transactions on Pattern Languages of Programming (hillside.net/tplop)
Books
hillside.net/patterns/books/index.htm for a partial index
33 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Ethics
Buschmann’s rule: Never capture your own ideas in a pattern
- Focus on broad, lasting, positive patterns
Intellectual currency paradox: Ideas are worth more if given away
• The author should retain ownership and copyright
“Aggressive Disregard for Originality” (Brian Foote)
Let’s encourage people to be secure in telling their secrets
Let’s reward people who created these techniques or who first took the trouble to commit them to writing
Patterns are solutions that have withstood the test of time
Don’t Hype!
34 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Using Patterns
35 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
“Patterns Generate Architectures”
Johnson, OOPSLA ’92
“Documenting Frameworks using Patterns”
Documented a framework using patterns
Beck and Johnson ECOOP ’94
“Patterns Generate Architectures”
Derived an architecture for a HotDraw interactive graphics system using patterns
36 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Documenting Architecture
Patterns are useful to document built systems.
Allows maintenance engineers a snapshot of the designer’s thinking.
Points out to the future maintainers/enhancers where the “load bearing walls”are.
Parnas & Clements: “A Rational Design Process: How and Why to Fake It”.
Example:
Architectural training for the 4ESS Switch project in Lucent Technologies
4ESS Switch design begun early 1970’s. First office application January 1976.
New enhancements are still being added.
Training uses patterns document key principles.
37 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Assisting Design
If you were designing an alarm component for a system, the Telecom IO Alarm patterns might be helpful.
Alarm Grid
Audible Alarm
Office Alarms
Don’t Let Them Forget
By examining these patterns you will see how to build such a component, and the order in which you should think about using them.
38 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Designing with Relevant Patterns
When starting a project that patterns and pattern languages might be useful for:
Create a list of the relevant patterns from the handbook (i.e. all available resources)
Example: to build a garden, Alexander suggests these patterns:
Half-Hidden GardenTerraced SlopeFruit TreesTree PlacesGarden Growing WildEntrance TransitionCourtyards Which LiveRoof Garden
Building EdgeSunny PlaceOutdoor RoomSix-Foot BalconyConnection to the EarthGreenhouseGarden Seat
TTWOB, p 310
39 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Using a Pattern language … “Never the same way twice.”
Applying a pattern language is not a “turn the crank” exercise.
Every application of patterns or pattern languages must be customized for the situation at hand.
Every situation poses unique problems.
Every situation requires a unique solution.
The pattern maps described earlier represent one way that the patterns can be combined to create a solution.
40 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Where do you find the patterns that you need?
Pattern Almanac
Lists all the patterns published up to mid-2000.
Web
Many websites contain links to patterns exist now.
hillside.net
www.welie.com
PLOP proceedings, TPLoP and PLOPD books.
Special topic books.
Basically: be familiar with the Handbook.
Writing and Collecting Patterns
42 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern mining
“… don’t count on being able to ‘mine’ a pattern language. A pattern language comes together like a jigsaw puzzle from patterns that have been collected over months, years or decades. At some point it becomes publishable, but its evolution doesn’t cease at that same point.”
– Coplien, C++ Report: Pattern Languages
43 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Digging deeper
What is required for this pattern to work?
What if absent would mean that this cannot work?
What’s missing?
“When every pattern has its principle components given by the smaller patterns which lie immediately below it in the language, then the language is complete.”
– TTWOB, p 322.
44 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Refactoring
Real Time and Resource Overload is an example of pattern refactoring.
It combines patterns from previous works into a language.
Meszaros, “A Pattern Language for Improving the Capacity of Reactive Systems”, PLOPD-2, ch 35.
Hanmer and Wu, “Traffic Congestion”, PLoP 1999 Proceedings.
Real Time and Resource overload Workshopped at PLOP 2000 conference.
Refactored again and included in Patterns for Fault Tolerant Software.
45 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Refactoring (2)
The pattern you are about to write to complete a language might already have been written by someone else.
Can you cite it and move on?
Do you need to rephrase it (continuing to give the original authors credit of course) to fit in your language?
46 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Pattern Research
Current Efforts
The Open Problem
47 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Handbook of Software Architecture
Grady Booch is collecting The Handbook of Software Architecture.http://www.handbookofsoftwarearchitecture.com
48 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
HCI Repository
Martijn van Welie has a repository of HCI patterns that many say is the cornerstone of the HCI community. http://www.welie.com
49 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Open Problem
Finding appropriate patterns
Many sources: books, web, articles
Many patterns with the same name: Null object, Shed Load
No centralized coordination
Some attempts to resolve
Many student projects to build repositories
Repository sites that wither and die
2000 2010
?
50 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Patterns in your Community
51 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Bioinformatics Open Source Patterns
How can you make use of patterns to foster development of “better”bioinformatics software?
Does that heading make sense?
What are the patterns that you have already mined?
What do you do with patterns?
Is there a repository?
Is there a “keeper” of the repository?
Wrapup
53 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
We’ve looked at
What pattern and pattern languages look like
Pattern communities
Some ways of using patterns
Some ideas about mining your patterns
The repository and indexing problem
Some thoughts about Bioinformatics patterns
54 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
Software Patterns for Reusable Design
A software pattern is a description of modular proven solution to a design problem with enough information so that the reader can flexibly adapt it to their unique situation.
A form of architectural documentation
An element of the pattern handbook
Is it part of the Handbook of Bioinformatics Open Source Software?
Questions?
55 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
References
Sources of more information
56 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
References (1)
Alexander, C. et. al. A Pattern Language. New York: Oxford University Press. 1977.
Alexander, C. The Timeless Way of Building. New York: Oxford University Press. 1979.
Beck, K. and R. Johnson, “Patterns Generate Architectures,” Object-Oriented Programming 8th European Conference (ECOOP ’94), Springer-Verlag, 1994.
Coplien, J. O. Software Patterns. New York: SIGS Publications. 1996.
Gabriel, R. P. Patterns of Software. New York: Oxford University Press. 1996.
Gamma, E., R. Helm, R. Johnson and J. Vlissides. Design Patterns: Elements of Re-usable object-Oriented Design. Addison-Wesley. 1994.
Hanmer, R. S. and G. Stymfal, “An Input and Output Pattern Language: Lessons fromTelecommunications”, in [14], pp 502-536.
Hanmer, R. S. Patterns for Fault Tolerant Software, Chichester: John Wiley & Sons. 2007.
Hanmer, R. S. “Using Patterns to Teach Software Architecture,” Proceedings of the 6th Biennial World Conference on Integrated Design and Process Technology, Pasadena, CA, June, 2002.
57 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
References (2)
Harrison, N., B. Foote, H. Rohnert, eds. Pattern Languages of Program Design-4. Reading, MA: Addison-Wesley, 2000.
PLOPD – PLOPD5: Pattern Languages of Program Design, volumes 1-5. Various editors. Reading, MA: Addison-Wesley, 1995-2006.
PLoP Conference Proceedings: http://hillside.net/plop/
POSA volumes: Pattern Oriented Software Architecture, volumes 1-5. Various authors. Chichester, John Wiley & Sons, 1996-2007.
Rising, L. The Pattern Alamanac 2000. Reading, MA: Addison-Wesley, 2000.
Rising, L. The Pattern Handbook. Cambridge: Cambridge University Press, 1998.
For more books see: http://hillside.net/patterns/books/index.htm
For pattern mailing lists see: http://hillside.net/patterns/mailing.htm
58 | Software Patterns for Reusable Design | June 2009 All Rights Reserved © Alcatel-Lucent 2009
www.alcatel-lucent.comwww.alcatel-lucent.com