software design and architecture lecture 31. review creational design patterns – singleton pattern...

16
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31

Upload: elmer-bradford

Post on 18-Jan-2016

227 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

SOFTWARE DESIGN AND ARCHITECTURE

LECTURE 31

Page 2: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Review

• Creational Design Patterns– Singleton Pattern– Builder Pattern

Page 3: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Outline

• Behavioral Patterns– Observer Pattern– Chain of command

Page 4: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Behavioral Patterns

• characterize the ways in which classes or objects interact and distribute responsibility.

• Behavioral class patterns:– use inheritance to describe algorithms and flow of

control• Behavioral object patterns:– describe how a group of objects cooperate to

perform a task that no single object can carry out alone.

Page 5: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

OBSERVER

Page 6: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Observer Design Pattern

Intent– Define a one-to-many dependency between objects so

that when one object changes state, all its dependents are notified and updated automatically.

• Encapsulate the core (or common or engine) components in a Subject abstraction, and the variable (or optional or user interface) components in an Observer hierarchy.

• The "View" part of Model-View-Controller.

Page 7: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 8: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 9: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 10: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Chain of Responsibility• Intent:– Avoid coupling the sender of a request to its receiver by

giving more than one object a chance to handle the request.

– Chain the receiving objects and pass the request along the chain until an object handles it.

Page 11: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 12: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

• The pattern chains the receiving objects together, and then passes any request messages from object to object until it reaches an object capable of handling the message.

• The number and type of handler• objects isn't known a priori, • they can be configured dynamically.

Page 13: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 14: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 15: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern
Page 16: SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern

Summary

• Behavioral Patterns– Observer Pattern– Chain of command