Design Patterns - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Design Patterns

Description:

describes the elements that make up the design, their relationships, ... Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 11
Provided by: anniegro
Category:
Tags: design | helm | patterns

less

Transcript and Presenter's Notes

Title: Design Patterns


1
Design Patterns
  • CS341
  • Western Washington University

2
What is a Design Pattern?
  • A solution to a problem in a context
  • 4 essential elements
  • Pattern name
  • a handle used to describe a design problem, its
    solutions, and consequences
  • Problem
  • describes when to apply the pattern
  • Solution
  • describes the elements that make up the design,
    their relationships, responsibilities, and
    collaborations
  • Consequences
  • the results and trade-offs of applying the pattern

3
The Gang of Four(GOF) Book
  • Design Patterns, Elements of Reusable
    Object-Oriented Software
  • Erich Gamma, Richard Helm, Ralph Johnson, and
    John Vlissides
  • Design patterns can be subjectivein the GOF
    book, design patterns are descriptions of
    communicating objects and classes that are
    customized to solve a general design problem in a
    particular context

4
MVC Classes
  • Model/View/Controller
  • Model is the application object
  • View is its screen representation
  • Controller defines the way the user interface
    reacts to user input
  • Decouples views and models by establishing a
    subscribe/notify protocol
  • This is how user interfaces are designed in
    Smalltalk-80

5
Describing a Pattern
  • Pattern name and classification
  • Intent
  • Also known as
  • Motivation
  • Applicability
  • Structure
  • Participants
  • Collaborations
  • Consequences
  • Implementation
  • Sample Code
  • Known Uses
  • Related Patterns

6
The Catalog of Design Patterns
  • Patterns are classified by 2 criterionpurpose
    and scope
  • Purpose reflects what a pattern does
  • Creational
  • concern the process of object creation
  • Structural
  • deal with the composition of classes or objects
  • Behavioral
  • characterize the ways classes or objects
    interact and distribute responsibility

7
  • Scope specifies whether the pattern applies
    primarily to classes or objects
  • Class patterns deal with relationships between
    classes and their subclasses
  • established via inheritance, at compile-time
  • Object patterns deal with object relationships
  • are more dynamic
  • most patterns are object patterns

8
Solving Problems with Design Patterns
  • Finding appropriate objects
  • Determine object granularity
  • Specifying object interfaces
  • Specifying object implementations
  • Putting reuse mechanisms to work
  • Relating run-time and compile-time structures
  • Designing for change

9
Choosing a Design Pattern
  • Consider how design patterns solve design
    patterns
  • Scan Intent sections
  • Study how patterns interrelate
  • Study patterns of like purpose
  • Examine a cause of redesign
  • Consider what should be variable

10
Using a Design Pattern
  • 1. Read pattern once through for an overview
  • 2. Go back and study the Structure,
    Participants, and Collaborations sections
  • 3. Look at the Sample Code section to see a
    concrete example of the pattern in code
  • 4. Choose names for pattern participants that
    are meaningful in the application context
  • 5. Define the classes
  • 6. Define application-specific names for
    operations in the pattern
  • 7. Implement the operations to carry out the
    responsibilities and collaborations in the pattern
Write a Comment
User Comments (0)
About PowerShow.com