Design Patterns Flashcards

1
Q

Observer (Publish-Subscribe)

A
  • Different kinds of subscriber objects are interested in the state changes or events of a publisher object, and want to react in their own unique way when the publisher generates an event. Publisher wants to maintain low coupling to the subscribers.
  • Solution: Define a “subscriber” or “listener” interface which Subscribers implement. The publisher can dynamically register subscribers who are interested in an event and notify them when an event occurs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Observer

A

• For example, when an item in a list changes, the on-screen list should
change.
• You could just send a message from the domain object to the UI object
• This would violate Model-View separation
• Thus various controls register for events, either external (button presses, keystrokes) or internal (new item added to a list) and act accordingly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

GRASP Patterns

A
  • Creator
  • Information Expert
  • Low Coupling
  • Controller
  • High Cohesion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly