Façade vs. Mediator

后端 未结 8 1394
粉色の甜心
粉色の甜心 2020-12-07 08:46

I\'ve been researching the difference between these two patterns.

I understand that facade encapsulates access to a sub system and mediator encapsulates the interac

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 09:14

    Both impose some kind of policy on another group of objects. Facade imposes the policy from above, and Mediator imposes the policy from below. The use of Facade is visible and constraining, while the use of Mediator is invisible and enabling.

    The Facade pattern is used when you want to provide a simple and specific interface to a group of objects that has a complex and general interface.

    The Mediator pattern also imposes policy. However, whereas Facade imposed its policy in a visible and constraining way, Mediator imposes its policies in a hidden and unconstrained way.

    Agile Software Development, Principles, Patterns, and Practices Robert C. Martin.

提交回复
热议问题