LAC Coding Seminar - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

LAC Coding Seminar

Description:

Factory. class VirtualFactory. virtual Product* create() = 0; template class T class Factory: public VirtualFacrtory. virtual Product ... Abstract Factory ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 29
Provided by: niti1
Category:

less

Transcript and Presenter's Notes

Title: LAC Coding Seminar


1
LAC Coding Seminar
  • Lecture 11
  • May 3, 2007

2
Design Pattern
3
Concept
  • General repeatable solution to a commonly
    occurring problem in software design.
  • Not software architecture.
  • Layered architecture, etc.
  • Not data structure.
  • Array, queue, etc.

4
Category of Patterns
  • Creational Pattern
  • Class/object instantiation
  • Structural Pattern
  • Class/object composition
  • Behavioral Pattern
  • Class/object communication

5
Factory
  • class VirtualFactory
  • virtual Product create() 0
  • template ltclass Tgt class Factory public
    VirtualFacrtory
  • virtual Product create() return new T

6
Abstract Factory
  • E.g. In a word process program, client can create
    multiple templates (Letter, Fax, Thesis), in
    different styles (Classic, Modern).

7
Builder
  • The builder pattern is used to create complex
    objects, which is usually in a composite pattern.

8
Prototype
  • Clone an identical copy

9
Singleton
  • If there is no instance of a class, create one
    otherwise return the reference to the existing
    one.

10
Adaptor/Wrapper
11
Facade
  • Wrap multiple classes and provide a simpler
    interface

12
Proxy
  • provides a placeholder for another object to
    control access, reduce cost, and reduce complexity

13
Bridge
  • decouple an abstraction from its implementation
    so that the two can vary independently
  • E.g., different shapes (circle, rectangle), each
    having independent properties (color, etc.)

14
Composite
  • "has-a" pattern
  • E.g., a group of objects with same behavior (a
    picture containing multiple objects that will
    resize with the picture)

15
Decorator
  • Add features/functionalities at run time
  • e.g., add new features to an existing window class

16
Flyweight
  • Reuse shared objects

17
Chains of Responsibility
  • delegates a series of commands to a chain of
    processing objects

18
Command
  • Encapsulate actions and parameters

19
Interpreter
  • Implements a special language
  • E.g., SQL, reverse polish notation

20
Iterator
  • accesses the elements of an object sequentially
    without exposing its underlying representation
  • E.g. STL

21
Mediator
  • allows loose coupling between classes by being
    the only class that has detailed knowledge of
    their methods.

22
Memento
  • provides the ability to restore an object to its
    previous state (undo).

23
State
  • allows an object to alter its behavior when its
    internal state changes

24
Observer
  • Publish/subscribe, callback

25
Strategy
  • Decouples an algorithm from its host
  • E.g., different sort algorithms on the same
    dataset

26
Visitor
  • separates an algorithm from an object structure
    by moving the hierarchy of methods into one
    object "double dispatching"

27
Template
  • defines the skeleton of an algorithm as an
    abstract class, allowing its subclasses to
    provide concrete behavior

28
Model-View-Controller
  • Model a domain-specific representation of data
  • View user interface
  • Controller processes and responds to events
Write a Comment
User Comments (0)
About PowerShow.com