mercredi 1 novembre 2017

Design pattern for decoupling master from slave, and creating a third party, for generic implementation?

What is a design pattern that decouples a relationship between a master and a slave, and inserts an intermediary for generic use?

Example:

  1. A colorpicker; User clicks on a little color box, and a flyout with a color wheel is displayed.
  2. A datepicker: User clicks on a drop-down, and a calendar appears, allowing them to select a date
  3. A select widget: User clicks a little down arrow, and is able to select from a list.

All of the above have a master-slave arrangement. User interaction with master triggers action from slave.

If we generalize this component, we can decouple the two, and insert an intermediary. That is, create three classes:

  • master: Generates generic events
  • intermediary: Enables between master and slave
  • slave: Responds to generic events

Now, we can generically implement a colorpicker, datepicker, and select widgets using this structure.

What is this design pattern called? Thx, Keith :^)

Aucun commentaire:

Enregistrer un commentaire