SlideShare a Scribd company logo
1 of 75
Design Patterns 05/28/10 Week 5: Observer and Decorator Jonathan Simon [email_address]
Weather Monitoring Application ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Observer Pattern ,[object Object],[object Object],05/28/10
Definitions ,[object Object],[object Object],[object Object],[object Object],05/28/10
Interfaces 05/28/10 Contains signatures for registering, removing, and notifying observers. Contains Update method so that information can be sent from Subject to Observer.
WeatherData (Subject) Questions:   Which field is used for storing the list of Observers?  How does an Observer add itself to this list? The fields for humidity, pressure, and temperature represent the state of the Subject.
WeatherData (Subject; Pt 1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Observers are notified since state has changed.
WeatherData (Subject; Pt2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Here is how the Subject sends information to all Observers
Current Conditions Display (Observer) Note that the individual Observer is composed of the Subject. So the Subjects has  a reference to all Observers…and each Observer has a reference to a Subject. Questions:  What method on this Observer is called by the Subject when data is changed?
CurrentConditionsDisplay (Observer) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
WeatherStation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab - Push ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lab - Pull ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lab – Refactor WeatherData ,[object Object],[object Object],[object Object],05/28/10
Refactoring WeatherData  ,[object Object],[object Object],[object Object],05/28/10
Subject ,[object Object],[object Object],[object Object],[object Object],05/28/10
Subject ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 What is wrong with NotifyObserver??
Subject ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Is this implying Push or Pull?
Observer ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Observer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
So far… 05/28/10 NotifyObserver will loop through each Observer and call Update() and pass a reference of itself Observer registers itself with the Subject
Concrete Subject ,[object Object],[object Object],[object Object],[object Object],05/28/10
ConcreteSubject ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Concrete Observer ,[object Object],[object Object],05/28/10
ConcreteObserver ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Client Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
The Big Picture 05/28/10
In Class Lab ,[object Object],[object Object],[object Object],[object Object],05/28/10
Multiple Events ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Problem ,[object Object],[object Object],05/28/10
Analysis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Analysis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Subject (Current Implementation) 05/28/10 Our Subject class contains the one notification event. Our ConcreteSubject gets the notification event by inheritance. We want our ConcreteSubject to contain multiple events.  Does Inheritance make sense??? Would could we use instead?
Subject/SubjectEvent 05/28/10 This class represents a specific event of the Subject.
SubjectEvent 05/28/10 Now the SubjectEvent, not Subject, contains a reference to all of the Observers who are interested in being notified.
Subject/SubjectEvent 05/28/10 The constructor of WeatherData takes a SubjectEvent as parameter.
WeatherData ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
SubjectEvent + Observers ,[object Object],[object Object],[object Object],[object Object],05/28/10
SubjectEvent  05/28/10 Added name parameter to the constructor and storing it in eventName Field.
SubjectEvent ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Cheating
Observer ,[object Object],[object Object],05/28/10
Observer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
CurrentConditionsDisplay ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Big Picture 05/28/10
Client Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Not done yet.. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
WeatherData (cont) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
ConcreteObserver ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Client Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Other Problems Arise.. ,[object Object],[object Object],05/28/10
Change Manager ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Features of the Change Manager ,[object Object],[object Object],[object Object],[object Object],05/28/10
Addressing Problem #2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Addressing Problem #2 (cont) ,[object Object],[object Object],[object Object],05/28/10
Using Event Infrastructure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Real World Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Solution #1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Problem #2 ,[object Object],[object Object],[object Object],[object Object],05/28/10
Solution #2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Problem #3 ,[object Object],[object Object],[object Object],05/28/10
Problem #3 (Cont) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Solution #3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solution #3 ,[object Object],[object Object],[object Object],05/28/10
Lab (Introduction to Decorator) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lab ,[object Object],[object Object],05/28/10
Problem ,[object Object],[object Object],[object Object],05/28/10
Solution ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 This is our Decorator class. In this example, it is extending the class that we want to enhance with additional functionality.
EncryptedLogger ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 This is the object we want to extend
CompressionLogger ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Client Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Decorator ,[object Object],05/28/10
Things to Note ,[object Object],[object Object],[object Object],05/28/10
Comparison to Other Patterns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10

More Related Content

What's hot

Hello, ReactorKit 
Hello, ReactorKit Hello, ReactorKit 
Hello, ReactorKit Suyeol Jeon
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaEdureka!
 
Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design PatternAdeel Riaz
 
React Interview Questions and Answers | React Tutorial | React Redux Online T...
React Interview Questions and Answers | React Tutorial | React Redux Online T...React Interview Questions and Answers | React Tutorial | React Redux Online T...
React Interview Questions and Answers | React Tutorial | React Redux Online T...Edureka!
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsMichael Heron
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternguy_davis
 
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...Edureka!
 
Spring Boot - Uma app do 0 a Web em 30 minutos
Spring Boot - Uma app do 0 a Web em 30 minutosSpring Boot - Uma app do 0 a Web em 30 minutos
Spring Boot - Uma app do 0 a Web em 30 minutosphelypploch
 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Sameer Rathoud
 
Javaday Paris 2022 - Java en 2022 : profiter de Java 17
Javaday Paris 2022 - Java en 2022 : profiter de Java 17Javaday Paris 2022 - Java en 2022 : profiter de Java 17
Javaday Paris 2022 - Java en 2022 : profiter de Java 17Jean-Michel Doudoux
 

What's hot (20)

Memento pattern
Memento patternMemento pattern
Memento pattern
 
Hello, ReactorKit 
Hello, ReactorKit Hello, ReactorKit 
Hello, ReactorKit 
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | Edureka
 
Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design Pattern
 
Visitor pattern
Visitor patternVisitor pattern
Visitor pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
React Interview Questions and Answers | React Tutorial | React Redux Online T...
React Interview Questions and Answers | React Tutorial | React Redux Online T...React Interview Questions and Answers | React Tutorial | React Redux Online T...
React Interview Questions and Answers | React Tutorial | React Redux Online T...
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Proxy Pattern
Proxy PatternProxy Pattern
Proxy Pattern
 
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...
React Components Lifecycle | React Tutorial for Beginners | ReactJS Training ...
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
 
Spring Boot - Uma app do 0 a Web em 30 minutos
Spring Boot - Uma app do 0 a Web em 30 minutosSpring Boot - Uma app do 0 a Web em 30 minutos
Spring Boot - Uma app do 0 a Web em 30 minutos
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
 
NestJS
NestJSNestJS
NestJS
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 
Javaday Paris 2022 - Java en 2022 : profiter de Java 17
Javaday Paris 2022 - Java en 2022 : profiter de Java 17Javaday Paris 2022 - Java en 2022 : profiter de Java 17
Javaday Paris 2022 - Java en 2022 : profiter de Java 17
 

Viewers also liked

Strategy and Template Pattern
Strategy and Template PatternStrategy and Template Pattern
Strategy and Template PatternJonathan Simon
 
MVC and Other Design Patterns
MVC and Other Design PatternsMVC and Other Design Patterns
MVC and Other Design PatternsJonathan Simon
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Sameer Rathoud
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator PatternAkshat Vig
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Patterneprafulla
 
Factory and Abstract Factory
Factory and Abstract FactoryFactory and Abstract Factory
Factory and Abstract FactoryJonathan Simon
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonJonathan Simon
 
Command and Adapter Pattern
Command and Adapter PatternCommand and Adapter Pattern
Command and Adapter PatternJonathan Simon
 
Observer Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 AugObserver Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 Augmelbournepatterns
 
Design patterns 4 - observer pattern
Design patterns   4 - observer patternDesign patterns   4 - observer pattern
Design patterns 4 - observer patternpixelblend
 
Design patterns: observer pattern
Design patterns: observer patternDesign patterns: observer pattern
Design patterns: observer patternJyaasa Technologies
 
Observer design pattern
Observer design patternObserver design pattern
Observer design patternSameer Rathoud
 
Design pattern - Software Engineering
Design pattern - Software EngineeringDesign pattern - Software Engineering
Design pattern - Software EngineeringNadimozzaman Pappo
 
Implementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsImplementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsSomenath Mukhopadhyay
 
Phani Kumar - Decorator Pattern
Phani Kumar - Decorator PatternPhani Kumar - Decorator Pattern
Phani Kumar - Decorator Patternmelbournepatterns
 
Decorator & Presenter Design Pattern
Decorator & Presenter Design PatternDecorator & Presenter Design Pattern
Decorator & Presenter Design PatternDonSchado
 

Viewers also liked (20)

Strategy and Template Pattern
Strategy and Template PatternStrategy and Template Pattern
Strategy and Template Pattern
 
MVC and Other Design Patterns
MVC and Other Design PatternsMVC and Other Design Patterns
MVC and Other Design Patterns
 
Design patterns - Observer Pattern
Design patterns - Observer PatternDesign patterns - Observer Pattern
Design patterns - Observer Pattern
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Factory and Abstract Factory
Factory and Abstract FactoryFactory and Abstract Factory
Factory and Abstract Factory
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and Singleton
 
Command and Adapter Pattern
Command and Adapter PatternCommand and Adapter Pattern
Command and Adapter Pattern
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Observer Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 AugObserver Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 Aug
 
Design patterns 4 - observer pattern
Design patterns   4 - observer patternDesign patterns   4 - observer pattern
Design patterns 4 - observer pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Design patterns: observer pattern
Design patterns: observer patternDesign patterns: observer pattern
Design patterns: observer pattern
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Design pattern - Software Engineering
Design pattern - Software EngineeringDesign pattern - Software Engineering
Design pattern - Software Engineering
 
Implementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsImplementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgets
 
15 decorator pattern
15 decorator pattern15 decorator pattern
15 decorator pattern
 
Phani Kumar - Decorator Pattern
Phani Kumar - Decorator PatternPhani Kumar - Decorator Pattern
Phani Kumar - Decorator Pattern
 
Decorator & Presenter Design Pattern
Decorator & Presenter Design PatternDecorator & Presenter Design Pattern
Decorator & Presenter Design Pattern
 

Similar to Observer and Decorator Pattern

Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7Vince Vo
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIEduardo Bergavera
 
Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton patternbabak danyal
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVMNetesh Kumar
 
Meteoio Introduction given by Mathias Bavey in Bozen
Meteoio Introduction given by Mathias Bavey in BozenMeteoio Introduction given by Mathias Bavey in Bozen
Meteoio Introduction given by Mathias Bavey in BozenRiccardo Rigon
 
Design patterns
Design patternsDesign patterns
Design patternsISsoft
 
The Singleton Pattern In Java
The Singleton Pattern In JavaThe Singleton Pattern In Java
The Singleton Pattern In JavaKohei Nozaki
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7Akash Tyagi
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptxDilanAlmsa
 
Effective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookEffective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookRoman Tsypuk
 
Handling Lifecycles in a Jetpack way
Handling Lifecycles in a Jetpack wayHandling Lifecycles in a Jetpack way
Handling Lifecycles in a Jetpack wayHan Yin
 
Concurrent talk
Concurrent talkConcurrent talk
Concurrent talkrahulrevo
 
Pointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
Pointer Events Working Group update / TPAC 2023 / Patrick H. LaukePointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
Pointer Events Working Group update / TPAC 2023 / Patrick H. LaukePatrick Lauke
 
Assignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfAssignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfjyothimuppasani1
 
Data binding in AngularJS, from model to view
Data binding in AngularJS, from model to viewData binding in AngularJS, from model to view
Data binding in AngularJS, from model to viewThomas Roch
 
Vigneshram murugan cloud project_documentation
Vigneshram murugan cloud project_documentationVigneshram murugan cloud project_documentation
Vigneshram murugan cloud project_documentationVigneshram Murugan
 

Similar to Observer and Decorator Pattern (20)

33071-AOOP-Exp6 (2).pdf
33071-AOOP-Exp6 (2).pdf33071-AOOP-Exp6 (2).pdf
33071-AOOP-Exp6 (2).pdf
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part II
 
Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton pattern
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
 
Sdp
SdpSdp
Sdp
 
Meteoio Introduction given by Mathias Bavey in Bozen
Meteoio Introduction given by Mathias Bavey in BozenMeteoio Introduction given by Mathias Bavey in Bozen
Meteoio Introduction given by Mathias Bavey in Bozen
 
Design patterns
Design patternsDesign patterns
Design patterns
 
The Singleton Pattern In Java
The Singleton Pattern In JavaThe Singleton Pattern In Java
The Singleton Pattern In Java
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
 
Effective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookEffective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's book
 
Handling Lifecycles in a Jetpack way
Handling Lifecycles in a Jetpack wayHandling Lifecycles in a Jetpack way
Handling Lifecycles in a Jetpack way
 
Concurrent talk
Concurrent talkConcurrent talk
Concurrent talk
 
Pointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
Pointer Events Working Group update / TPAC 2023 / Patrick H. LaukePointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
Pointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
 
Assignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfAssignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdf
 
Data binding in AngularJS, from model to view
Data binding in AngularJS, from model to viewData binding in AngularJS, from model to view
Data binding in AngularJS, from model to view
 
Vigneshram murugan cloud project_documentation
Vigneshram murugan cloud project_documentationVigneshram murugan cloud project_documentation
Vigneshram murugan cloud project_documentation
 

Recently uploaded

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Recently uploaded (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Observer and Decorator Pattern

  • 1. Design Patterns 05/28/10 Week 5: Observer and Decorator Jonathan Simon [email_address]
  • 2.
  • 3.
  • 4.
  • 5. Interfaces 05/28/10 Contains signatures for registering, removing, and notifying observers. Contains Update method so that information can be sent from Subject to Observer.
  • 6. WeatherData (Subject) Questions: Which field is used for storing the list of Observers? How does an Observer add itself to this list? The fields for humidity, pressure, and temperature represent the state of the Subject.
  • 7.
  • 8.
  • 9. Current Conditions Display (Observer) Note that the individual Observer is composed of the Subject. So the Subjects has a reference to all Observers…and each Observer has a reference to a Subject. Questions: What method on this Observer is called by the Subject when data is changed?
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. So far… 05/28/10 NotifyObserver will loop through each Observer and call Update() and pass a reference of itself Observer registers itself with the Subject
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. The Big Picture 05/28/10
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. Subject (Current Implementation) 05/28/10 Our Subject class contains the one notification event. Our ConcreteSubject gets the notification event by inheritance. We want our ConcreteSubject to contain multiple events. Does Inheritance make sense??? Would could we use instead?
  • 34. Subject/SubjectEvent 05/28/10 This class represents a specific event of the Subject.
  • 35. SubjectEvent 05/28/10 Now the SubjectEvent, not Subject, contains a reference to all of the Observers who are interested in being notified.
  • 36. Subject/SubjectEvent 05/28/10 The constructor of WeatherData takes a SubjectEvent as parameter.
  • 37.
  • 38.
  • 39. SubjectEvent 05/28/10 Added name parameter to the constructor and storing it in eventName Field.
  • 40.
  • 41.
  • 42.
  • 43.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.

Editor's Notes

  1. 13 November 2008
  2. Interface breaks. By value. The Observer needs to have it’s own version of the state data. Problem is that the Subject sends a lot more information that needed. We can resolve by sending a null value for data that has not changed. 13 November 2008
  3. 1. No. We would need to cast the subject to a specific subject so that we can get the properties that we want. This ties our Observer to a very specific Subject. Note with the Push model, the Observer did not need to know about the Subject data. 13 November 2008
  4. 1. reigsterObserver removeObserver notifyObservers 2. ArrayList observers 3. Initialize the ArrayList of observers 13 November 2008
  5. Temperature, humidity, and pressure aren’t part of a generic subject. 13 November 2008
  6. The Subject passed on a reference to itself. The SubjectEvent needs to pass the Subject as well. The SubjectEvent needs to tell the Observer the name of the event. 13 November 2008
  7. Observer = Search Screen. Just one observer Multiple Subjects 13 November 2008
  8. Observers = Each Child Node Subject = Parent Node 13 November 2008