week 4 day 3 observer continued
Download
Skip this Video
Download Presentation
Week 4, Day 3 Observer, continued

Loading in 2 Seconds...

play fullscreen
1 / 8

Week 4, Day 3 Observer, continued - PowerPoint PPT Presentation


  • 118 Views
  • Uploaded on

Week 4, Day 3 Observer, continued. Return Quiz Coupling & Cohesion Observers Class structure for observers Sequence diagram for observers How it improves coupling How it improves cohesion Downsides Exam next week (Week 5), Tuesday. Coupling vs. Cohesion.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Week 4, Day 3 Observer, continued' - halen


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
week 4 day 3 observer continued
Week 4, Day 3Observer, continued
  • Return Quiz
    • Coupling & Cohesion
  • Observers
    • Class structure for observers
    • Sequence diagram for observers
    • How it improves coupling
    • How it improves cohesion
    • Downsides
  • Exam next week (Week 5), Tuesday

SE-2811

Slide design: Dr. Mark L. Hornick

Content: Dr. Hornick

Errors: Dr. Yoder

coupling vs cohesion
Coupling vs. Cohesion
  • Module 4 shows what we are trying to avoid: low cohesion and high coupling

(more lines==lower)

(more lines==higher)

SE-2811

Dr. Mark L. Hornick

http://www.jesusgilhernandez.com/2012/11/28/cohesion-and-coupling/

basic class relationships
Basic class relationships

Subject

------------------------------

attach():voiddetach():voidnotifyObservers():void

Observer----------------

update(???):void

-observers

1..*

SubjectClass

ObserverClass1

ObserverClass2

collaborations between objects in the observer pattern
Collaborations between objects in the Observer pattern

s:SubjectClass

o1:ObserverClass1

o2:ObserverClass2

attach(???)

attach(???)

notifyObservers()

update(???)

getContextSpecificInfo()

update(???)

getContextSpecificInfo()

consequences positive
Consequences (positive)

Coupling between Subject and Observers:

  • Subject knows it has a list of Observers, but not specific classes
  • Each Observer conforms to the simple interface of the abstract Observer Interface.
  • Hence, coupling is
    • Minimal
    • Abstract
consequences positive1
Consequences (positive)

Cohesion is increased from single-class implementation

  • State management and display/response are separated
  • E.g. GUI innards separated from “your code”
  • E.g. Web access separated from display
consequences negative
Consequences (negative)
  • Broadcast communication
    • Notification is broadcast to all interested objects.
    • Observers can be added/removed at any time.
    • Observer decides when it needs to be notified.
  • Unexpected updates
    • Observers have no knowledge
      • Of each other’s presence.
      • About the cost of “state change of subject”
    • Cascade of updates.

SE-2811

Dr. Mark L. Hornick

added slide timing of multiple observers
[ADDED SLIDE]Timing of multiple observers
  • All observers get notified at essentially the same time.
  • In the lab, all observers should be integrated into the same program and run at the same time.

SE-2811

Dr. Mark L. Hornick

ad