DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

13
DESIGN PATTERNS DESIGN PATTERNS CSC532 Adv. Topics in CSC532 Adv. Topics in Software Engineering Software Engineering Shirin A. Lakhani Shirin A. Lakhani

Transcript of DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Page 1: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

DESIGN PATTERNSDESIGN PATTERNS

CSC532 Adv. Topics in Software CSC532 Adv. Topics in Software EngineeringEngineering

Shirin A. LakhaniShirin A. Lakhani

Page 2: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

IntroductionIntroduction

A pattern is the outline of a reusable solution A pattern is the outline of a reusable solution to a general problem encountered in a to a general problem encountered in a particular context particular context

The recurring aspects of designs are called The recurring aspects of designs are called design patterns design patterns

Rational reconstruction of existing Rational reconstruction of existing programming practiceprogramming practice

Page 3: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Essential ElementsEssential Elements

NameName: Good pattern name form vocabulary for : Good pattern name form vocabulary for commonly commonly

ProblemProblem: Problem statement which describes its : Problem statement which describes its intentintent

ContextContext: It tells us patterns applicability: It tells us patterns applicability ForcesForces: Forces reveal the intricacies of a : Forces reveal the intricacies of a

problem and defines trade-offsproblem and defines trade-offs Solution: Solution: It should describe static relationships It should describe static relationships

and dynamic rulesand dynamic rules

Page 4: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Essential ElementsEssential Elements

Examples:Examples: One or more sample applications of the One or more sample applications of the pattern pattern

Resulting Context: Resulting Context: The state or configuration of the The state or configuration of the system after the pattern has been applied system after the pattern has been applied

Rationale: Rationale: A justifying explanation of steps or rules in A justifying explanation of steps or rules in the pattern the pattern

Related Patterns:Related Patterns: Predecessor patterns, successor Predecessor patterns, successor patterns, alternative patterns, and codependent patterns patterns, alternative patterns, and codependent patterns

Known Uses:Known Uses: Describes known occurrences of the Describes known occurrences of the pattern and its application within existing systems. pattern and its application within existing systems.

Page 5: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Criteria which design pattern Criteria which design pattern should meetshould meet

Focus on practicability Focus on practicability

Aggressive disregard of originalityAggressive disregard of originality

Non-anonymous review Non-anonymous review

Writer's workshops instead of Writer's workshops instead of

presentations presentations

Careful editing Careful editing

Page 6: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Qualities of PatternQualities of Pattern

Encapsulation and AbstractionEncapsulation and Abstraction

Openness and VariabilityOpenness and Variability

Generativity and ComposabilityGenerativity and Composability

EquilibriumEquilibrium

Page 7: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Why Design Patterns ?Why Design Patterns ?

Solve "real world" problemsSolve "real world" problems Document design decisions and Document design decisions and

rationalerationale Convey expert insight to novicesConvey expert insight to novices Form a shared vocabulary for problem-Form a shared vocabulary for problem-

solving discussionsolving discussion Record experience in designing object Record experience in designing object

oriented software as design patterns.oriented software as design patterns. Capture experience in the form of a Capture experience in the form of a

catalog.catalog. Help software developersHelp software developers

Page 8: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Benefits of using Design Benefits of using Design PatternsPatterns

A Common Design VocabularyA Common Design Vocabulary

A Documentation and Learning AidA Documentation and Learning Aid

An adjunct to existing methodsAn adjunct to existing methods

Page 9: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Drawbacks of using Design Drawbacks of using Design PatternsPatterns

Patterns do not lead to direct code Patterns do not lead to direct code reuse.reuse.

Patterns are deceptively simple.Patterns are deceptively simple.

Patterns are validated by experiencePatterns are validated by experience

It is a human-intensive activity.It is a human-intensive activity.

Page 10: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Software Patterns are…Software Patterns are…

Recurring solution to common problem Recurring solution to common problem

of designof design

Practical/concrete solutions to real Practical/concrete solutions to real

world problemsworld problems

Context specificContext specific

““Best-fits” for the given set of Best-fits” for the given set of

concerns/trade-offsconcerns/trade-offs

Page 11: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Software Patterns are notSoftware Patterns are not Restricted to software design or Restricted to software design or

Object-Oriented designObject-Oriented design Untested ideas/theories or new Untested ideas/theories or new

inventionsinventions Solutions that have worked only onceSolutions that have worked only once Any old thing written-up in pattern Any old thing written-up in pattern

formatformat Abstract principles or heuristicsAbstract principles or heuristics Universally applicable for all contextsUniversally applicable for all contexts A “silver bullet” or panaceaA “silver bullet” or panacea

Page 12: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Design PatternsDesign Patterns Creational PatternsCreational Patterns

Abstract Factory PatternAbstract Factory PatternBuilder PatternBuilder PatternFactory Method Pattern TestFactory Method Pattern TestPrototype PatternPrototype PatternSingleton PatternSingleton Pattern

Structural PatternsStructural PatternsAdapter PatternAdapter PatternBridge PatternBridge PatternComposition PatternComposition PatternDecorator PatternDecorator PatternFaçade PatternFaçade PatternFlyweight PatternFlyweight PatternProxy PatternProxy Pattern

Page 13: DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.

Design PatternsDesign Patterns Behavioral PatternsBehavioral Patterns

Chain of Responsibility PatternChain of Responsibility Pattern Command PatternCommand Pattern Interpreter PatternInterpreter Pattern Iterator PatternIterator Pattern Mediator PatternMediator Pattern Memento PatternMemento Pattern Observer PatternObserver Pattern State PatternState Pattern Strategy PatternStrategy Pattern Template Method PatternTemplate Method Pattern Visitor PatternVisitor Pattern