observer pattern aleksandar kartelj. ideja not long ago my clutch gave out, so i had my jeep towed...

7
Observer pattern Aleksandar Kartelj

Upload: mae-neal

Post on 06-Jan-2018

213 views

Category:

Documents


0 download

DESCRIPTION

Primene u stvarnom životu Newsletter, grupe Pretplata na časopis Obaveštenja javnih službi Sudski pozivi itd...

TRANSCRIPT

Page 1: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Observer pattern

Aleksandar Kartelj

Page 2: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Ideja• Not long ago my clutch gave out, so I had my Jeep

towed to a local dealership. I didn't know anybody at the dealership, and none of them knew me, so I gave them my telephone number so they could notify me with an estimate. That arrangement worked so well we did the same thing when the work was finished. Because this all turned out perfectly for me, I suspect the service department at the dealership employs the same pattern with most of its customers.

Page 3: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Primene u stvarnom životu

• Newsletter, grupe• Pretplata na časopis• Obaveštenja javnih službi• Sudski pozivi itd...

Page 4: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

UML model Observera

Page 5: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Primene u programiranju

1. MVC je baziran na Observeru – Smalltalk2. Document View Architecture – skoro

ekvivalentno MVC-u (Ažuriranje promena u različitim pogledima istog dokumenta)

Page 6: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Observer u javi

• Observer interfejs– update

• Observable klasa– addObserver– notifyObservers

Page 7: Observer pattern Aleksandar Kartelj. Ideja Not long ago my clutch gave out, so I had my Jeep towed to a local dealership. I didn't know anybody at the

Jedna promena – više zainteresovanih

• Primer sa bojenjem polja