Upload
osborne-french
View
217
Download
0
Embed Size (px)
DESCRIPTION
2001 Lodewijk Bergmans University of Twente Generative Patterns vThe structure of the pattern is not the solution itself, but it generates the solution vGenerative patterns explicitly describe when & how they should be applied to generate an appropriate solution
Citation preview
2001 Lodewijk Bergmans
Universityof Twente
Pattern LanguagesPattern Languages
2001 Lodewijk Bergmans
Universityof Twente
What is a Pattern Language?What is a Pattern Language?
A collection of patterns that build on each other to generate a 'system' Not a programming language!
2001 Lodewijk Bergmans
Universityof Twente
Generative PatternsGenerative Patterns
The structure of the pattern is not the solution itself, but it generates the solution
Generative patterns explicitly describe when & how they should be applied to generate an appropriate solution
2001 Lodewijk Bergmans
Universityof Twente
Pattern LanguagePattern Language Examples Examples
Examples: Design patterns
Telecommunications softwareFinances,
Analysis patterns:Accountability (Fowler)
Others:Testing (Firesmith)Process patterns (Coplien)
2001 Lodewijk Bergmans
Universityof Twente
Pattern SystemPattern System(defined by Buschman et.al.)(defined by Buschman et.al.)
A pattern system for software architecture is: A collection of patterns for software architecture Guidelines for:
implementation, combination & practical use of patterns Thus, must be:
Uniform representaion Organize (relations between) patterns Support its own evolution
Difference with pattern language?
2001 Lodewijk Bergmans
Universityof Twente
Pattern Language Example:Pattern Language Example:
"Evolving Frameworks""Evolving Frameworks"
2001 Lodewijk Bergmans
Universityof Twente
Three ExamplesThree Examples
How to start designing a framework? develop abstractions by generalizing concrete
examples (‘too hard’ the other way around)Therefore, develop three applications in the
domain of the framework these should pay for themselves common abstractions should become apparent develop in parallel or sequential
2001 Lodewijk Bergmans
Universityof Twente
White-box FrameworksWhite-box FrameworksProblem & Forces:Problem & Forces:
Context: develop 2nd application Use inheritance or aggregration?
inheritance:stronger coupling, staticmodify (override) reused component
aggregation (polymorphic composition)fixed interfaces (must anticipate changes)dynamically change more difficult to understand (statically)
white-box
2001 Lodewijk Bergmans
Universityof Twente
White-box FrameworksWhite-box FrameworksSolutionSolution
Therefore, use inheritance generalize classes in the individual applications to
abstract superclassesMove all the common behavior there
This is the most straightforward way to distinguish special cases from general
2001 Lodewijk Bergmans
Universityof Twente
Component LibraryComponent Library
Context: developing 2nd+ examples based on the white-box framework
Problem: similar objects have to be written for each example These are hard to predict
Therefore, develop library of reusable (?) objects as you need them
2001 Lodewijk Bergmans
Universityof Twente
Hot SpotsHot Spots
Context: Adding components to component library
Problem: Similar code written (overridden) repeatedly
Forces: Changeable code scattered: difficult to manage Changeable code grouped: program flow
continuously involves the changeable code (object) Solution????
2001 Lodewijk Bergmans
Universityof Twente
Hot SpotsHot Spots
SolutionSolution Separate code that changes from code that
doesn't Encapsulate varying code in objects when
possible: Easier to reuse Many examples exist:
Which pattern separates algorithms?Which pattern separates Implementations?What does Observer separate?What does Abstract Factory Separate?
2001 Lodewijk Bergmans
Universityof Twente
Hot SpotsHot Spots
ExamplesExamples What varies?
Algorithms: Strategy & Visitor
Implementations: Bridge
Response to change: Observer
Object being created: Factory Method, Abstract Factory, Prototype
2001 Lodewijk Bergmans
Universityof Twente
Pluggable ObjectsPluggable Objects
Context: Adding components to your library Problem: Subclasses differ in trivial ways
E.g. just one method redefined Forces:
complex parameterized classes difficult Many new classes reduce overview
Therefore, design adaptable subclasses Offer interface to change parameters
2001 Lodewijk Bergmans
Universityof Twente
Fine-Grained ObjectsFine-Grained Objects
Context: refactoring your component library to make it more reusable
Problem: How far to go in dividing into smaller objects? Forces:
More objects -> more difficult to manage Applications can be created by composing objects that
implement desired functionality Therefore, break into smallest useful objects and offer
tools to provide the composition (and manage many objects)
2001 Lodewijk Bergmans
Universityof Twente
Black-box FrameworkBlack-box Framework
Context: developing Pluggable objects by encapsulating hot spots and making fine-grained objects
Problem: rely on inheritance or aggregation ('polymorphic composition')?
Therefore, use inheritance to organize your component library and aggregation to construct applications black-box
2001 Lodewijk Bergmans
Universityof Twente
Finally: Two Tool patternsFinally: Two Tool patterns
Visual Builder Graphically compose the configuration of all the
components in your black-box framework Language Tools
Dedicated tools are needed to inspect & debug your 'domain-specific language' programs
2001 Lodewijk Bergmans
Universityof Twente
SummarySummary
Pattern Language:Pattern Language: A collection of patterns that build on each
other to generate a 'system' Coherence: domain specific
'any knowledge domain' Relations must be explicit & constructive A pattern language is much more than the sum of
its parts!
2001 Lodewijk Bergmans
Universityof Twente
when 2 patterns are parallel on time line, they may go in arbitrary order
2001 Lodewijk Bergmans
Universityof Twente
Composition in OOComposition in OO
OO FrameworksOO Frameworks OO library = (micro-)architecture + collection of variations (classes) e.g. MVC
“Society is composed of two great classes:those who have more dinners than appetite, and those who have more appetite than dinners.”
--Sebastian Chamfort--
+
framework:
2001 Lodewijk Bergmans
Universityof Twente
Composition in OOComposition in OO
White-box frameworksWhite-box frameworksWhite-box frameworks
inheritance-based adapt reused class by :
adding methods & variablesoverriding methodsself calls with dynamic binding
Characteristics: more dependencies to the reused classes
because the subclasses have more access Automatic (cascaded) updates of an interface
to the classes that reuse it Static, composition relation cannot be adapted at run-time
white-box
2001 Lodewijk Bergmans
Universityof Twente
Composition in OO Composition in OO
Black-box frameworksBlack-box frameworks Black-box frameworks
aggregation-based composition-interface equals
message interface adapt reused class by:
adding methods & variablesredefining methodsselective reuse of interface methods
Characteristics:+ more robust; depends only on the invocation interface+ Supports dynamic reconfiguration.- Requires explicit message forwarding for interface reuse
requires adding many extra methods, lacks the notion of 'self'
black-box