Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000.

Similar presentations


Presentation on theme: "1 Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000."— Presentation transcript:

1 1 Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000

2 Software Architecture2 Motivation n Vehicle for reasoning about design or architecture at a higher level of abstraction (design confidence) n Mining or discovering design patterns in legacy systems n Software architecture dissemination of good design, design reusedissemination of good design, design reuse n Engineering Handbooks contain a wealth of experiencecontain a wealth of experience

3 Software Architecture3 Software Patterns n Design patterns [GoF] n Pattern languages [Coplien] n Software idioms [Coplien] n Analysis patterns [Fowler] n AntiPatterns [Brown] n Frameworks n STL (C++ Template Library) n Algorithms and data structures

4 Software Architecture4 Software Patterns... n Conceptual patterns n Architectural patterns n Design patterns n Generative patterns n Programming patterns or idioms n Analysis patterns n AntiPatterns n Organizational patterns

5 Software Architecture5 Pattern Definitions n A pattern is a named nugget of insight that conveys the essence of a proven solution to a recurring problem within a certain context amidst competing concerns [Riehle] n A pattern is the abstraction from a concrete form which keeps recurring in specific non-arbitrary contexts.

6 Software Architecture6 Pattern Definitions... n A pattern is a named nugget of instructive information that captures the essential structure and insight of a successful family of proven solutions to a recurring problem that arises within a certain context and system forces.

7 Software Architecture7 Pattern Definitions... n Description of communicating objects and classes that are customized to solve a general design in a particular context [GoF]. n Design patterns capture the static and dynamic structures of solutions that occur repeatedly when producing applications in a particular context [Coplien].

8 Software Architecture8 Historical Perspective on Design Patterns n 1979 Alexander’s Timeless Way of BuildingAlexander’s Timeless Way of Building n 1987 OOPSLA workshop by Beck & WardOOPSLA workshop by Beck & Ward n 1994 First PLoP conferenceFirst PLoP conference n 1995 GoF (Gamma, Helm, Johnson, Vlissides)GoF (Gamma, Helm, Johnson, Vlissides) Design Patterns; Elements of Reusable Object-Oriented SoftwareDesign Patterns; Elements of Reusable Object-Oriented Software

9 Software Architecture9 A Good Pattern n It solves a problem Patterns capture solutions, not just abstract principles or strategiesPatterns capture solutions, not just abstract principles or strategies n It is a proven concept Patterns capture solutions with a track record, not theories or speculationPatterns capture solutions with a track record, not theories or speculation n The solution isn’t obvious The best patterns generate a solution indirectly; normal for many design problemsThe best patterns generate a solution indirectly; normal for many design problems

10 Software Architecture10 A Good Pattern... n It describes a relationship Patterns describe more than black boxes: system structures and mechanismsPatterns describe more than black boxes: system structures and mechanisms n The pattern has a significant human component The best patterns explicitly appeal to aesthetics and utilityThe best patterns explicitly appeal to aesthetics and utility

11 Software Architecture11 Patterns Formats n GoF format n Alexandrian form (canonical form) n Essential components of a pattern format Name, problem, context, forcesName, problem, context, forces Solution, examples, context,Solution, examples, context, Rationale, related patterns, known usesRationale, related patterns, known uses

12 Software Architecture12 Pattern Format... n Name meaningful phrasemeaningful phrase n Problem a statement of the problem which describes its intent: the goals and objectives it wants to reach within the given context and forcesa statement of the problem which describes its intent: the goals and objectives it wants to reach within the given context and forces

13 Software Architecture13 Pattern Format... n Context preconditions under which the problem and its solutions seem to occurpreconditions under which the problem and its solutions seem to occur the pattern’s applicabilitythe pattern’s applicability may change over timemay change over time n Forces relevant forces and constraints and their interactions and conflictsrelevant forces and constraints and their interactions and conflicts motivational scenario for the patternmotivational scenario for the pattern

14 Software Architecture14 Pattern Format... n Solution Static and dynamic relationships describing how to realize the patternStatic and dynamic relationships describing how to realize the pattern instructions on how to construct the work products instructions on how to construct the work products pictures, diagrams, prose which highlight the pattern’s structure, participants, and collaborationspictures, diagrams, prose which highlight the pattern’s structure, participants, and collaborations

15 Software Architecture15 Pattern Format... n Examples one or more sample applications to illustrateone or more sample applications to illustrate –a specific context –how the pattern is applied n Resulting context the state or configuration after the pattern has been appliedthe state or configuration after the pattern has been applied consequences (good and bad) of applying the patternconsequences (good and bad) of applying the pattern

16 Software Architecture16 Pattern Format... n Rationale justification of the steps or rules in the patternjustification of the steps or rules in the pattern how and why it resolves the forces to achieve the desired goals, principles, and philosophieshow and why it resolves the forces to achieve the desired goals, principles, and philosophies how are the forces orchestrated to achieve harmonyhow are the forces orchestrated to achieve harmony how does the pattern actually workhow does the pattern actually work

17 Software Architecture17 Pattern Format... n Related patterns the static and dynamic relationships between this pattern and other patternsthe static and dynamic relationships between this pattern and other patterns n Known uses to demonstrate that this is a proven solution to a recurring problemto demonstrate that this is a proven solution to a recurring problem

18 Software Architecture18 Qualities of a Pattern n Encapsulation and abstraction encapsulates a well-defined problem and its solution in a particular domainencapsulates a well-defined problem and its solution in a particular domain provides crisp, clear boundaries to crystallize the problem and solution spacesprovides crisp, clear boundaries to crystallize the problem and solution spaces serves as an abstraction which embodies domain knowledge and experienceserves as an abstraction which embodies domain knowledge and experience may occur at different levels of abstractionmay occur at different levels of abstraction

19 Software Architecture19 Qualities of a Pattern... n Openness and variability is open for extension and parameterization by other patternsis open for extension and parameterization by other patterns is able to solve larger problems in concert with other patternsis able to solve larger problems in concert with other patterns can be realized by a variety of implementations (variants)can be realized by a variety of implementations (variants)

20 Software Architecture20 Qualities of a Pattern... n Generativity and composability applying a pattern once provides a context for further applicationsapplying a pattern once provides a context for further applications patterns are easier to apply in another context than C++ codepatterns are easier to apply in another context than C++ code can evolve into Golden Hammer AntiPatterncan evolve into Golden Hammer AntiPattern

21 Software Architecture21 Qualities of a Pattern... n Equilibrium realizes a balance among its forces and constraintsrealizes a balance among its forces and constraints realizes an invariant, heuristics, or a policy which minimizes conflict within the solution spacerealizes an invariant, heuristics, or a policy which minimizes conflict within the solution space an invariant characterizes the problem solving philosophyan invariant characterizes the problem solving philosophy

22 Software Architecture22 GoF Catalog of 23 Design Patters n Creational patterns Creational patterns Creational patterns Abstract the instantiation processAbstract the instantiation process Make the system independent on how the objects are created, composed, and representedMake the system independent on how the objects are created, composed, and represented –Abstract Factory Abstract FactoryAbstract Factory –Builder Builder –Factory Method Factory MethodFactory Method –Prototype Prototype –Singleton Singleton

23 Software Architecture23 GoF Catalog of 23 Design Patters... n Structural patterns Structural patterns Structural patterns Composition of classes and objects to form larger structuresComposition of classes and objects to form larger structures Compose classes to form new interfacesCompose classes to form new interfaces Compose objects to provide new functionalityCompose objects to provide new functionality –Adaptor Adaptor –Bridge Bridge –Composite Composite –Decorator Decorator –Façade Façade –Flyweight Flyweight –Proxy Proxy

24 Software Architecture24 GoF Catalog of 23 Design Patters... n Behavioral patterns Behavioral patterns Behavioral patterns concerned with algorithms and the assignment of responsibilities among objectsconcerned with algorithms and the assignment of responsibilities among objects –Chain of Responsibility –Command –Interpreter –Iterator Iterator –Mediator –Memento –Observer –State –Strategy –Template Method –Visitor

25 Software Architecture25 Summary n Vehicle for reasoning about design, architecture, component technology n GoF book is great but there are many other software patterns


Download ppt "1 Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000."

Similar presentations


Ads by Google