powerpoint templates

33
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB

Upload: alyson

Post on 22-Feb-2016

46 views

Category:

Documents


0 download

DESCRIPTION

What is Design Patterns ? by Indriati Teknik Informatika – UB. Powerpoint Templates. Outline. Background Pattern origins and history Definition Elements of Design Patterns Desing Patterns are NOT Where Design Patterns are used Describing Design Patterns Types of patterns. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Powerpoint Templates

Powerpoint Templates Page 1Powerpoint Templates

What is Design Patterns ?

by IndriatiTeknik Informatika – UB

Page 2: Powerpoint Templates

Powerpoint Templates Page 2

Outline• Background

• Pattern origins and history

• Definition

• Elements of Design Patterns

• Desing Patterns are NOT

• Where Design Patterns are used

• Describing Design Patterns

• Types of patterns

Page 3: Powerpoint Templates

Powerpoint Templates Page 3

Background1

• Search for recurring successful designs – emergent designs from practice (via trial and error)

• Supporting higher levels of reuse (i.e., reuse of designs) is quite challenging

• Described in Gama, Helm, Johnson, Vlissides 1995 (i.e., “gang of 4 book”)

• Based on work by Christopher Alexander (an Architect) on building homes, buildings and towns.

Page 4: Powerpoint Templates

Powerpoint Templates Page 4

Background2

• Design patterns represent solutions to problems that arise when developing software within a particular context. E.g., problem/solution pairs within a given context

• Describes recurring design structures• Describes the context of usage

Page 5: Powerpoint Templates

Powerpoint Templates Page 5

Background3

• Patterns capture the static and dynamic structure and collaboration among key participants in software designs

• Especially good for describing how and why to resolve nonfunctional issues

• Patterns facilitate reuse of successful software architectures and designs.

Page 6: Powerpoint Templates

Powerpoint Templates Page 6

Pattern origins and history• writings of architect Christopher Alexander

(coined this use of the term "pattern" ca. 1977-1979) • Kent Beck and Ward Cunningham, Textronix,

OOPSLA'87(used Alexander's "pattern" ideas for Smalltalk GUI design)

• Erich Gamma, Ph. D. thesis, 1988-1991 • James Coplien, Advanced C++ Idioms book, 1989-1991 • Gamma, Helm, Johnson, Vlissides ("Gang of Four“ -

GoF)Design Patterns: Elements of Reusable Object-Oriented Software, 1991-1994

• PLoP Conferences and books, 1994-present• Buschmann, Meunier, Rohnert, Sommerland, Stal,

Pattern -Oriented Software Architecture: A System of Patterns (“POSA book”)

Page 7: Powerpoint Templates

Powerpoint Templates Page 7

Definition• … a fully realized form, original, or

model accepted or proposed for imitation…[dictionary]

• ... describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice [Alexander]

Page 8: Powerpoint Templates

Powerpoint Templates Page 8

Definition

• a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

[Wikipedia]

Page 9: Powerpoint Templates

Powerpoint Templates Page 9

Definition• … the abstraction from a concrete

form which keeps recurring in specific non-arbitrary contexts [Riehle]

• …both a thing and the instructions for making the thing [Coplien]

• ...a literary format for capturing the wisdom and experience of expert designers, and communicating it to novices

Page 10: Powerpoint Templates

Powerpoint Templates Page 10

Elements of Design Patterns

• Design patterns have four essential elements:– Pattern name– Problem– Solution– Consequences

Page 11: Powerpoint Templates

Powerpoint Templates Page 11

Pattern Name• A handle used to describe:

– a design problem– its solutions– its consequences

• Increases design vocabulary• Makes it possible to design at a higher

level of abstraction• Enhances communication• “The Hardest part of programming is

coming up with good variable [function, and type] names.”

Page 12: Powerpoint Templates

Powerpoint Templates Page 12

Problem• Describes when to apply the

pattern• Explains the problem and its

context• May describe specific design

problems and/or object structures• May contain a list of preconditions

that must be met before it makes sense to apply the pattern

Page 13: Powerpoint Templates

Powerpoint Templates Page 13

Solution• Describes the elements that make

up the– design– relationships– responsibilities– collaborations

• Does not describe specific concrete implementation

• Abstract description of design problems and how the pattern solves it

Page 14: Powerpoint Templates

Powerpoint Templates Page 14

Consequences• Results and trade-offs of applying the

pattern• Critical for:

– evaluating design alternatives– understanding costs– understanding benefits of applying the

pattern• Includes the impacts of a pattern on a

system’s:– flexibility– extensibility– portability

Page 15: Powerpoint Templates

Powerpoint Templates Page 15

Design Patterns are NOT

• Designs that can be encoded in classes and reused as is (i.e., linked lists, hash tables)

• Complex domain-specific designs (for an entire application or subsystem)

• They are:– “Descriptions of communicating objects

and classes that are customized to solve a general design problem in a particular context.”

Page 16: Powerpoint Templates

Powerpoint Templates Page 16

Where They are Used• Object-Oriented programming

languages [and paradigm] are more amenable to implementing design patterns

• Procedural languages: need to define– Inheritance– Polymorphism– Encapsulation

Page 17: Powerpoint Templates

Powerpoint Templates Page 17

Describing Design Patterns• Graphical notation is generally not

sufficient• In order to reuse design decisions

the alternatives and trade-offs that led to the decisions are critical knowledge

• Concrete examples are also important

• The history of the why, when, and how set the stage for the context of usage

Page 18: Powerpoint Templates

Powerpoint Templates Page 18

Design Patterns

• Describe a recurring design structure– Defines a common vocabulary – Abstracts from concrete designs– Identifies classes, collaborations,

and responsibilities– Describes applicability, trade-offs,

and consequences

Page 19: Powerpoint Templates

Powerpoint Templates Page 19

Alexandrian form (canonical form)Name

meaningful nameProblem

the statement of the problemContext

a situation giving rise to a problemForces

a description of relevant forces and constraints

Solution proven solution to the problem

Examples sample applications of the pattern

Page 20: Powerpoint Templates

Powerpoint Templates Page 20

Alexandrian form (canonical form)

Resulting context (force resolution)the state of the system after pattern has been applied

Rationale explanation of steps or rules in the pattern

Related patterns static and dynamic relationship

Known useoccurrence of the pattern and its application within existing system

Page 21: Powerpoint Templates

Powerpoint Templates Page 21

GoF formatPattern name and classification Intent

what does pattern do / when the solution works Also known as

other known names of pattern (if any)Motivation

the design problem / how class and object structures solve the problem

Applicability situations where pattern can be applied

Structure a graphical representation of classes in the pattern

Participants the classes/objects participating and their responsibilities

Collaborations of the participants to carry out responsibilities

Page 22: Powerpoint Templates

Powerpoint Templates Page 22

GoF formatConsequences

trade-offs, concerns Implementation

hints, techniquesSample code

code fragment showing possible implementation

Known uses patterns found in real systems

Related patternsclosely related patterns

Page 23: Powerpoint Templates

Powerpoint Templates Page 23

Types of Patterns

• Creational patterns:– Deal with initializing and configuring

classes and objects• Structural patterns:

– Deal with decoupling interface and implementation of classes and objects

– Composition of classes or objects• Behavioral patterns:

– Deal with dynamic interactions among societies of classes and objects

– How they distribute responsibility

Page 24: Powerpoint Templates

Powerpoint Templates Page 24

Creational Patterns

• Abstract Factory:– Factory for building related objects

• Builder:– Factory for building complex objects incrementally

• Factory Method:– Method in a derived class creates associates

• Prototype:– Factory for cloning new instances from a prototype

• Singleton:– Factory for a singular (sole) instance

Page 25: Powerpoint Templates

Powerpoint Templates Page 25

Structural Patterns• Adapter:

– Translator adapts a server interface for a client• Bridge:

– Abstraction for binding one of many implementations

• Composite:– Structure for building recursive aggregations

• Decorator:– Decorator extends an object transparently

• Facade:– Simplifies the interface for a subsystem

• Flyweight:– Many fine-grained objects shared efficiently.

• Proxy:– One object approximates another

Page 26: Powerpoint Templates

Powerpoint Templates Page 26

Behavioral Patterns• Chain of Responsibility:

– Request delegated to the responsible service provider

• Command:– Request is first-class object

• Iterator:– Aggregate elements are accessed sequentially

• Interpreter:– Language interpreter for a small grammar

• Mediator:– Coordinates interactions between its associates

• Memento:– Snapshot captures and restores object states

privately

Page 27: Powerpoint Templates

Powerpoint Templates Page 27

Behavioral Patterns (cont.)

• Observer:– Dependents update automatically when subject

changes• State:

– Object whose behavior depends on its state• Strategy:

– Abstraction for selecting one of many algorithms• Template Method:

– Algorithm with some steps supplied by a derived class

• Visitor:– Operations applied to elements of a heterogeneous

object structure

Page 28: Powerpoint Templates

Powerpoint Templates Page 28

Design Pattern Space

Chain of responsibilityCommandIteratorMediatorMementoObserverStateStrategyVisitor

Adapter (object)BridgeCompositeDecoratorFaçadeFlyweightProxy

Abstract factoryBuilderPrototypeSingleton

Object

InterpreterTemplate method

Adapter (class)Factory methodClassScope

BehavioralStructuralCreationalPurpose

Page 29: Powerpoint Templates

Powerpoint Templates Page 29

Categorization Terms

• Scope is the domain over which a pattern applies– Class Scope: relationships between

base classes and their subclasses (static semantics)

– Object Scope: relationships between peer objects

• Some patterns apply to both scopes.

Page 30: Powerpoint Templates

Powerpoint Templates Page 30

Class::Creational

• Abstracts how objects are instantiated

• Hides specifics of the creation process

• May want to delay specifying a class name explicitly when instantiating an object

• Just want a specific protocol

Page 31: Powerpoint Templates

Powerpoint Templates Page 31

AssignmentPresentation topic1. Abstract factory+builder2. Factory Method+prototype+singleton3. Bridge+ Flyweight4. Composite+decorator  5. Adapter +Facade+Proxy6. Command+Chain of responsibility7. Iterator+Interpreter8. Memento+mediator 9. Template Method+Strategy10. Visitor+observer+state11. Agile Development

Page 32: Powerpoint Templates

Powerpoint Templates Page 32

Rules of the class• Run in Seminar Style

– Each class consists of two or three student presentations of design patterns

– Each presentation is followed by a discussion of the material presented

• Prepare a Power-Point presentation– Description of each type of design pattern– A piece of code to representation the type of

design pattern– Demo (optional)

Page 33: Powerpoint Templates

Powerpoint Templates Page 33

Deadline: Sept 22, 2010 Email to : [email protected] : [ topic ]