Introduction Continued Design Patterns I - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Introduction Continued Design Patterns I

Description:

Like a class library, but more than an ordinary toolkit. ... Happy/Gloomy Example. State Pattern. Book discussion. Applicability: state dependent behavior ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 16
Provided by: cunx
Learn more at: https://www.cse.scu.edu
Category:

less

Transcript and Presenter's Notes

Title: Introduction Continued Design Patterns I


1
Introduction (Continued)Design Patterns (I)
  • Lecture Two

2
What is a framework
  • Like a class library, but more than an ordinary
    toolkit. The framework components have structural
    and behavioral relations among them.
  • Domain specific
  • business, telecom, window systems, databases, OS
    kernels,

3
What is a framework
  • An integrated set of cooperating classes
  • architectural design of oo system
  • semi-complete application
  • set of abstract class are specialized in
    application

4
Frameworks
  • Inversion of control
  • main event loop is often in framework, rather
    than in application code
  • hollywood principle dont call us, well call
    you
  • code in framework can invoke code in application
    by dynamic binding

5
Framework examples
  • UI
  • model-view-controller (MVC)
  • framework for smalltalk user interfaces 1980
  • macapp - framework for Mac applications 1986
  • Others
  • MFC - Microsoft foundation classes
  • Choices - operating system framework
  • ..

6
Patterns vs Frameworks
  • Patterns
  • reuse of design
  • tells you how to do good design
  • language independent
  • often covers general domains
  • addresses small part of a program architecture

7
Patterns vs Frameworks
  • Framework
  • reuse of design and code
  • is a design (generic implementation)
  • language specific
  • often covers specific domain
  • addresses overall program architecture

8
State Pattern
  • Butterfly Example
  • Caterpillar
  • Chrysalis
  • Adult
  • Happy/Gloomy Example

9
State Pattern
  • Book discussion
  • Applicability
  • state dependent behavior
  • large conditional statements
  • Scheme structure/participants/collaborations
  • Benefits
  • extensibility
  • make state transitions explicit
  • can be shared (flyweight)

10
State Pattern
  • Implementation
  • Who defines state transitions?
  • How about table-driven
  • Manage lifetime of state objects
  • relation with Singleton
  • How about use dynamic inhertiance

11
Singleton Pattern
  • What is it?
  • How to implement?

12
Homework Digital Watch
  • Demo
  • Code explained

13
Composite Pattern
  • Objective treat primitives and containers
    uniformly
  • java.awt.
  • Example Basket

14
Composite Pattern
  • Consequences
  • recursive composition
  • uniform interface
  • easier to add new components
  • can make design overly general

15
Implementation Issues
  • Explicit parent references
  • Sharing components
  • Maximizing the Component interface
  • Child management operations
  • Who implements a list of components
  • Child ordering
  • Who should delete components
  • Best structures for storing components
Write a Comment
User Comments (0)
About PowerShow.com