Upload
jenn
View
59
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Patterns and AntiPatterns. Ku-Yaw Chang [email protected] Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Outline. Background Structured v.s. Object-Oriented Paradigm Patterns Command AntiPatterns BLOB Summary References. - PowerPoint PPT Presentation
Citation preview
Patterns and AntiPatternsPatterns and AntiPatterns
Ku-Yaw ChangKu-Yaw [email protected]@mail.dyu.edu.tw
Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information EngineeringComputer Science and Information Engineering
Da-Yeh UniversityDa-Yeh University
222004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
OutlineOutline
BackgroundBackground Structured v.s. Object-Oriented ParadigmStructured v.s. Object-Oriented Paradigm
PatternsPatterns CommandCommand
AntiPatternsAntiPatterns BLOBBLOB
SummarySummaryReferencesReferences
332004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
ParadigmParadigmA way of organizing system A way of organizing system abstractionsabstractions around properties of around properties of commonalitycommonality and and variationvariation..
442004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
ParadigmParadigmAbstractionAbstraction To focus on the general andTo focus on the general and
put aside the specific. put aside the specific. To emphasize what is common and To emphasize what is common and
deemphasize details deemphasize details
552004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
ParadigmParadigmCommonalityCommonality The Essence of AbstractionThe Essence of Abstraction To search for common elements that helps us To search for common elements that helps us
understand how family members are the understand how family members are the same.same.
VariabilityVariability The Spice of AbstractionThe Spice of Abstraction Being monotonous without variability.Being monotonous without variability.
662004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
ParadigmParadigmA way of organizing system A way of organizing system abstractionsabstractions around properties of around properties of commonalitycommonality and and variationvariation.. CommonalityCommonality
The backbone and skeleton of designThe backbone and skeleton of design VariabilityVariability
The flesh and bloodThe flesh and blood
772004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
ParadigmParadigmBefore 1975Before 1975 No specific techniquesNo specific techniques
1975 – 19851975 – 1985 Structured ParadigmStructured Paradigm
Functional DecompositionFunctional Decomposition
1985 – 20041985 – 2004 Object-Oriented ParadigmObject-Oriented Paradigm
882004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Structured v.s.Structured v.s.Object-Oriented ParadigmObject-Oriented Paradigm
accountbalance
withdrawdeposit
determinebalance
accountbalance
deposit withdraw
determinebalance
message
message message
992004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
BackgroundBackground
True Object OrientationTrue Object OrientationAlan ShallowayAlan Shalloway The objects in my code were well-formed and The objects in my code were well-formed and
tightly encapsulated. I could design excellent tightly encapsulated. I could design excellent data abstractions for inheritance hierarchies. I data abstractions for inheritance hierarchies. I thought I knew object-orientation.thought I knew object-orientation.
Now, looking back, I see that I really did not Now, looking back, I see that I really did not understand understand the full capabilitiesthe full capabilities of object- of object-oriented design.oriented design.
I know there was a better design.I know there was a better design.I just couldn’t see it.I just couldn’t see it.
10102004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns
Having roots in the architecture field by Having roots in the architecture field by Christopher AlexanderChristopher Alexander
11112004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns
12122004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns
13132004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns
Expert behaviorExpert behavior do not try to find the solution from first principlesdo not try to find the solution from first principles reuse the essence of a proven solution to solve the reuse the essence of a proven solution to solve the
new problemnew problem
14142004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns
Being applied to the software development Being applied to the software development successfully, especially in the object-oriented successfully, especially in the object-oriented communitycommunitySoftware reuseSoftware reuse Code reuse Code reuse Design reuseDesign reuse
the value of design experiencethe value of design experienceLayers : OSI 7-Layer ModelLayers : OSI 7-Layer Model
15152004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
What is a Pattern?What is a Pattern?
Christopher AlexanderChristopher Alexander Each pattern describes a Each pattern describes a problemproblem which occurs over which occurs over
and over again in our environment, and then and over again in our environment, and then describes the core of the describes the core of the solutionsolution to that problem, in to that problem, in such a way that you can use this solution a million such a way that you can use this solution a million times over, without ever doing it the same way twice.times over, without ever doing it the same way twice.
Be applied in developing software in 1987.Be applied in developing software in 1987.Enter the mainstream of OO community in Enter the mainstream of OO community in 1994(1st PLoP)1994(1st PLoP)
16162004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PLoP ConferencesPLoP Conferences
Pattern Languages of ProgramPattern Languages of Program PLoPPLoP Chili PLoPChili PLoP Euro PLoPEuro PLoP Koala PLoPKoala PLoP Mensore PLoPMensore PLoP SugarLoaf PLoPSugarLoaf PLoP Viking PLoPViking PLoP OOPSLAOOPSLA ECOOPECOOP
Allerton Park
17172004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
PatternsPatterns What is a Pattern?What is a Pattern?
Four Essential ElementsFour Essential Elements pattern namepattern name
easier to think and to communicateeasier to think and to communicate problemproblem
explain the problem and its contextexplain the problem and its contextdescribe when to applydescribe when to apply
solutionsolutiondescribe the elementsdescribe the elementstheir relationships, responsibilities, and collaborationstheir relationships, responsibilities, and collaborations
consequenceconsequenceresults and trade-offsresults and trade-offs
18182004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Pattern ExamplePattern Example
Pattern NamePattern Name CommandCommand
Pattern ProblemPattern Problem different requestdifferent request queue or log requestqueue or log request support undoable operationssupport undoable operations
19192004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Pattern ExamplePattern Example
Solution Solution (UML)(UML)
20202004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Pattern ExamplePattern Example
ConsequencesConsequences Decouples the object that invokes the Decouples the object that invokes the
operation from the one that knows how to operation from the one that knows how to perform it.perform it.
Commands can be manipulated and extended Commands can be manipulated and extended like any other object.like any other object.
Assemble commands into a composite Assemble commands into a composite command.command.
Easy to add new Commands. You don’t have Easy to add new Commands. You don’t have to change existing classes.to change existing classes.
21212004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Non-software Pattern ExampleNon-software Pattern Example
SolutionSolution
22222004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
GoF - 94GoF - 94CreationalCreational Patterns Patterns
Abstract FactoryAbstract Factory SingletonSingleton
StructuralStructural Patterns Patterns DecoratorDecorator
BehavioralBehavioral Patterns Patterns CommandCommand
Pattern CategoriesPattern Categories
23232004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
POSA (Vol. One) - 96POSA (Vol. One) - 96ArchitecturalArchitectural
MVC / Doc-ViewMVC / Doc-View BrokerBroker
DesignDesign ProxyProxy
IdiomsIdioms
Pattern CategoriesPattern Categories
24242004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
POSA (Vol. Two) - 2000POSA (Vol. Two) - 2000Service Access and Service Access and Configuration Configuration Event HandlingEvent HandlingSynchronizationSynchronizationConcurrencyConcurrency
Pattern CategoriesPattern Categories
25252004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Obsessive use of 1 patternObsessive use of 1 pattern
There are more than There are more than 160160 fundamental fundamental patterns:patterns: 23 Gamma Patterns23 Gamma Patterns 33 Buschmann Patterns (16+17)33 Buschmann Patterns (16+17) 72 Analysis Patterns72 Analysis Patterns 38 CORBA Design Patterns38 CORBA Design Patterns ……..
26262004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Bright and Dark SidesBright and Dark Sides
Bright sideBright side Reuse of proven good designsReuse of proven good designs Can be applied in constructing new softwareCan be applied in constructing new software
Dark sideDark side Fail to properly evaluate a patternFail to properly evaluate a pattern Difficult to be applied to existing systemsDifficult to be applied to existing systems
27272004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
The Truth aboutThe Truth aboutSoftware TechnologySoftware Technology
84% 84% of software projects are unsuccessful.of software projects are unsuccessful.
VendorsVendorsOur new technology Our new technology changes the whole changes the whole paradigm. paradigm. We’ll have all the features We’ll have all the features you need in six months.you need in six months.We make no warranty We make no warranty express. If it does something express. If it does something bad, it’s not their fault.bad, it’s not their fault.Proprietary technologies Proprietary technologies change every 4 to 18 change every 4 to 18 months.months.
Software gurusSoftware gurusNew method improves New method improves anything they said in the anything they said in the past.past.You need more tools!You need more tools!You need more training!You need more training!You need more consultancy!You need more consultancy!
28282004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Many Paths to DisasterMany Paths to DisasterStructured Programming
Artificial IntelligenceNetworking Technologies
Open SystemsParallel Processing
29292004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
AntiPatternsAntiPatterns
NegativeNegative solutions that present more problems solutions that present more problems than they addressthan they addressNatural extension to design patternsNatural extension to design patternsBridge the gap between architectural concepts Bridge the gap between architectural concepts and real-world implementationsand real-world implementationsProvide the knowledge to prevent or recover Provide the knowledge to prevent or recover from themfrom them
30302004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
AntiPattern ResearchAntiPattern Research
“ “The presence of ‘good’ patterns in a successful system The presence of ‘good’ patterns in a successful system is not enough; you also must show that those patterns is not enough; you also must show that those patterns are absent in unsuccessful systems. Likewise, it is useful are absent in unsuccessful systems. Likewise, it is useful to show the presence of certain patterns(AntiPatterns) in to show the presence of certain patterns(AntiPatterns) in unsuccessful systems, and their absence in successful unsuccessful systems, and their absence in successful systems.systems.
- James O. Coplien- James O. Coplien
31312004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
AntiPattern ResearchAntiPattern Research
Principal viewpointsPrincipal viewpoints DevelopmentDevelopment AntiPatterns AntiPatterns
Technical problems and solutions encountered by Technical problems and solutions encountered by programmersprogrammers
ArchitecturalArchitectural AntiPatterns AntiPatternsIdentify and resolve common problems in how Identify and resolve common problems in how systems are structured.systems are structured.
ManagerialManagerial AntiPatterns AntiPatternsAddress common problems in software processes Address common problems in software processes and development organizations.and development organizations.
32322004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
AntiPattern ResearchAntiPattern Research
33332004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Design Pattern and AntiPatternDesign Pattern and AntiPattern
34342004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Software RefactoringSoftware Refactoring
A form of code modification, used to A form of code modification, used to improve the software structure in support improve the software structure in support of subsequent extension and long-term of subsequent extension and long-term maintenance.maintenance.AntiPatternsAntiPatterns Define a migration (or refactoring) from Define a migration (or refactoring) from
negative solutions to positive solutions.negative solutions to positive solutions. Not only do they point out trouble, but they Not only do they point out trouble, but they
also tell you how to get out it.also tell you how to get out it.
35352004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
The BlobThe Blob
General FormGeneral Form One class monopolizes the processing and One class monopolizes the processing and
other classes primarily encapsulate data.other classes primarily encapsulate data.
Key ProblemKey Problem The majority of the responsibility are allocated The majority of the responsibility are allocated
to a single class.to a single class. Procedural-style rather than object-oriented Procedural-style rather than object-oriented
architecturesarchitectures
36362004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
37372004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
38382004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
39392004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
40402004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
41412004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
42422004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
SummarySummary
Structured v.s. Object Oriented ParadigmsStructured v.s. Object Oriented ParadigmsPatterns help Patterns help reuse design experiencesreuse design experiences
Especially in constructing new softwareEspecially in constructing new software understand the full capabilities of object-understand the full capabilities of object-
oriented designoriented design communication communication
43432004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
SummarySummary
AntiPatternsAntiPatterns not against using patterns.not against using patterns. a more compelling form of patterns.a more compelling form of patterns.Each AnitPattern includes a solution + Each AnitPattern includes a solution + solution pair.solution pair. AntiPattern Solution Generates mostly AntiPattern Solution Generates mostly
negative consequences.negative consequences. Refactored Solution Generates mostly Refactored Solution Generates mostly
positive benefits.positive benefits.
44442004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
SummarySummary
A B
RulesRules What to doWhat to do What not to doWhat not to do
45452004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
ReferencesReferencesPatternsPatterns
GoF:GoF:E. Gamma, E. Helm, R. Johnson and J. Vlissides, E. Gamma, E. Helm, R. Johnson and J. Vlissides, Design Design Patterns - Elements of Reusable Object-Oriented SoftwarePatterns - Elements of Reusable Object-Oriented Software, , Addison-Wesley Publishing Company Inc., 1995.Addison-Wesley Publishing Company Inc., 1995.
POSA (Vol. 1):POSA (Vol. 1):F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad and M. F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad and M. Stal, Stal, Pattern-Oriented Software Architecture – A System of Pattern-Oriented Software Architecture – A System of PatternsPatterns, John Wiley & Sons Inc., New York, 1996., John Wiley & Sons Inc., New York, 1996.
POSA (Vol. 2):POSA (Vol. 2):D. Schmidt, M. Stal, H. Rohnert and F. Buschmann, D. Schmidt, M. Stal, H. Rohnert and F. Buschmann, Pattern-Pattern-Oriented Software Architecture – Patterns for Concurrent and Oriented Software Architecture – Patterns for Concurrent and Networked ObjectsNetworked Objects, John Wiley & Sons Inc., New York, 2000., John Wiley & Sons Inc., New York, 2000.
46462004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
ReferencesReferences
AntiPatternsAntiPatterns W. J. Brown, R. C. Malveau, H. W. McCormick III, T. J. W. J. Brown, R. C. Malveau, H. W. McCormick III, T. J.
Mowbray, Mowbray, AntiPatterns - Refactoring Software, Architectures, AntiPatterns - Refactoring Software, Architectures, and Projects in Crisisand Projects in Crisis, John Wiley & Sons Inc., New York, 1998. , John Wiley & Sons Inc., New York, 1998.
Web SitesWeb Sites http://hillside.net/patterns/http://hillside.net/patterns/ http://www.antipatterns.com/http://www.antipatterns.com/
47472004/05/212004/05/21 Patterns and AntiPatternsPatterns and AntiPatterns
Q & AQ & A
Thank you!Thank you!