design pattern n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Design Pattern PowerPoint Presentation
Download Presentation
Design Pattern

Loading in 2 Seconds...

play fullscreen
1 / 37

Design Pattern - PowerPoint PPT Presentation


  • 158 Views
  • Uploaded on

Design Pattern. Dr. Zhen Jiang West Chester University E-mail: zjiang@wcupa.edu url: www.cs.wcupa.edu/~zjiang. Outline. Introduction Creational Patterns Structural Patterns Behavioral Patterns. Introduction.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Design Pattern' - asher


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
design pattern

Design Pattern

Dr. Zhen Jiang

West Chester University

E-mail: zjiang@wcupa.edu

url: www.cs.wcupa.edu/~zjiang

outline
Outline
  • Introduction
  • Creational Patterns
  • Structural Patterns
  • Behavioral Patterns
introduction
Introduction
  • A design pattern names, abstracts, and identifies the key aspects of a common design structure that make it useful for creating a reusable object-oriented design
  • Creational design patterns abstracts the instantiation process
  • Structural patterns are concerned with how classes and objects are composed to form larger structures.
  • Behavioral patterns are concerned with algorithms and assignment of responsibilities between objects.
creational pattern
Creational Pattern
  • Abstract factory
  • Builder
  • Factory Method
  • Prototype
  • Singleton
abstract factory
Abstract Factory
  • Consider a user interface (client, windows and ScrollBar) that supports (creates) multiple look-and-feel standards.

Client

WidgetFactory

Windows

PMW

Motif

Motif

PMW

ScrollBar

?

PMW

Motif

abstract factory1
Abstract Factory

Client

AbstractFactory

ProductA

PA2

PA1

Factory1

Factory2

ProductB

PB2

PB1

abstract factory2
Abstract Factory
  • Shopping, interlibrary, …
builder
Builder
  • Add a new conversion?

Converter

Reader/User

ACS

Widget

Text

Picture

builder1
Builder

Builder

Reader/User

ConcreteBuilder

Product

builder2
Builder
  • Add a new tool, new course, new equipment, …
factor method
Factor Method
  • For creating objects
  • Drink, Drug, vegetables, gardening, …

Product

Creator

ConcreteProduct

ConcreteCreator

prototype
Prototype
  • Provide an abstract tool for defining items like those in the palette.
  • Windows creation

Prototype

Client

clone

movement

Prototype1

Prototype2

clone

clone

singleton
Singleton
  • For some classes to have exactly one instance
  • Examples?
structural pattern
Structural Pattern
  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Façade
  • Flyweight
  • Proxy
adapter
Adapter
  • For existing and unrelated classes working in an application that expects classes with a different and incompatible interfaces (Builder?)
  • Unix process, file system, …

Adaptee

Client

Target

implementation

Adapter

request

bridge
Bridge
  • Inheritance binding (Builder? AbstractFactory?)
  • Windows (their structure and implementation), Database?

Implementor

Abstraction

IA

IB

RefinedAbstraction

composite
Composite
  • Group components

Component

Leaf

Composite

composite1
Composite

aComposite

(is aComponent)

aComponent

aComponent

aComponent

aLeaf

aComposite

aLeaf

aComponent

aComponent

aLeaf

aLeaf

decorator
Decorator
  • Specifying the responsibility of certain group, build an transparent interface to component’s client
  • Teaching, GA, and Instructor

Component

Leaf

Decorator

ops

DA

DB

ops

ops

facade
Facade
  • Simplifying interface to more general facilities of subsystems. (AbstractFactory, FactorMethod, Bridge)
  • Current screen status of Windows?

Facade

flyweight
Flyweight
  • For sharing resource

FlyWeight

Client

ConcreteFlyWeight

flyweight1
Flyweight

aFlyWeight

aClient

aCF

aClient

aCF

flyweight2
Flyweight

Paragraph and Keys of keyboard?

proxy
Proxy
  • Access control and reference

Subject

Proxy

RealSubject

aClient

aProxy

aRS

proxy1
Proxy
  • Network Service?
behavioral pattern
Behavioral Pattern
  • Chain of Responsibility
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template Method
  • Visitor
chain of responsibility
Chain of Responsibility
  • Decouple senders and receivers (sequence? )
  • Steps, courses, …

Handler

aHandler

aHandler

aHandler

command
Command
  • Request, command, …?
  • Dos/Shell command, file I/O, user interface, …?

Invoker

Command

Receiver

ConcreteCommand

interpreter
Interpreter
  • Grammar
  • Composite?
  • Formal language L=a|bC; C=e|cC. (sample statement: a, b, bc, bcc, …
iterator
Iterator
  • Access without exposing any internal structure
  • Interface
  • FactorMethod
mediator
Mediator
  • Distribution of behavior among objects
  • AbstractFactory

Mediator

Colleague

CC1

CC2

ConcreteMediator

memento
Memento
  • Record the internal state (checkpoints)
  • Tests of course, firewall, …?

Originator

Memento

Caretaker

observer
Observer
  • Maintain consistency
  • Observer calls Getstatus( )
  • Ordering, TCP communication, …

Subject

Observer

ConcreteSubject

ConcreteObserver

state
State
  • Conditional statements
  • Used in Command, Memento, Observer, …
  • Project, study, …,

Context

State

ConcreteStateA

ConcreteStateB

strategy
Strategy
  • Builder, Prototype, Bridge, Command, State.
  • Hollywoodsquare, Chess, searching and sorting (for example, shell), …

Context

Strategy

ConcreteStrategyA

ConcreteStrategyB

template method
Template Method
  • A template method defines an algorithm in terms of abstract operations that subclasses override to provide concrete behavior
  • Inheritance (generalization), virtual function
  • Operations (searching and sorting) in Template class (Template Stack, Template Queue).

AbstractClass

ConcreteClass

visitor
Visitor
  • Packaging related operations from each class in a separate object, called a visitor, and passing it to elements of the abstract syntax tree as it’s traversed.

Visitor

ConcreteAcceptA

ConcreteAcceptB

ConcreteVisitorA

ConcreteVisitorB

ConcreteAcceptA

ConcreteAcceptB