Evgenii Legotckoi
Evgenii LegotckoiSept. 27, 2018, 5:11 a.m.

Structural Design Patterns - Facade

Goals

  • Provide a unified interface for a set of interfaces in a subsystem. A facade defines a higher-level interface that makes the subsystem easier to use.
  • Wrap a complex subsystem with a simpler interface.

Problems

The client access segment requires a simplified interface to access the common functionality of a complex subsystem.


Discussion

A facade encapsulates a complex subsystem within a single interface. This reduces the learning curve needed to successfully use the subsystem. It also helps decouple the subsystem from potentially many clients. On the other hand, if the Facade is the only access point for a subsystem, this will limit the power and flexibility that "advanced users" may want.

The Facade object should be a fairly simple intermediary. It should not become an omniscient oracle or a "divine" entity.

Structure

The façade takes "an enigma wrapped in an enigma shrouded in mystery" and adds a shell that tames an amorphous and incomprehensible mass of software to provide a simple and understandable client interface.

SubsystemOne and SubsystemThree do not interact with SubsystemTwo internals. They use a SubsystemTwoWrapper "facade" (i.e. a higher level abstraction).

Example

A facade defines a higher-level unified interface to a subsystem that makes it easier to use. Consumers face a facade when ordering from a catalog. A consumer calls one number and talks to a customer service representative. The customer service representative acts as a front, providing an interface to the order fulfillment, billing, and shipping departments.

Control List

  1. Define a simpler unified interface for a subsystem or component.
  2. Create a 'wrapper' class that encapsulates the subsystem.
  3. Facade/wrapper eliminates the complexity and interaction with the component by delegating the appropriate methods.
  4. The client uses (attached to) only the facade.
  5. Consider whether the facade will add additional value and functionality.

Rules of thumb

  • Facade defines a new interface, while Adapter uses the old interface. Remember that an adapter supports two existing interfaces, not defines a completely new one.
  • While Flyweight shows how to make many small objects, Facade shows how to make one object representing an entire subsystem.
  • A mediator is similar to a Facade in that it abstracts the functionality of existing classes. The mediator abstracts/centralizes arbitrary relationships between peer objects. In contrast, Facade defines a simpler interface for a subsystem, it does not add new functionality, and it is not known to subsystems.
  • Abstract Factory can be used as an alternative to Facade to hide platform-specific classes.
  • Facade objects are often singletons because only one Facade object is required.
  • Adapter and facade - both wrappers; but they are different kinds of wrappers. The purpose of a Facade is to create a simpler interface, and the purpose of an adapter is to develop an existing interface. While a Facade typically wraps multiple objects, an Adapter wraps a single object; The facade could have an interface complex with a single complex object, and the adapter could wrap multiple legacy objects.
We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
ИМ
Игорь МаксимовNov. 22, 2024, 11:51 a.m.
Django - Tutorial 017. Customize the login page to Django Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
Evgenii Legotckoi
Evgenii LegotckoiOct. 31, 2024, 2:37 p.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 8:19 a.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 7:51 a.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 11:02 a.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
Now discuss on the forum
m
moogoNov. 22, 2024, 7:17 a.m.
Mosquito Spray System Effective Mosquito Systems for Backyard | Eco-Friendly Misting Control Device & Repellent Spray - Moogo ; Upgrade your backyard with our mosquito-repellent device! Our misters conce…
Evgenii Legotckoi
Evgenii LegotckoiJune 24, 2024, 3:11 p.m.
добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
t
tonypeachey1Nov. 15, 2024, 6:04 a.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
NSProject
NSProjectJune 4, 2022, 3:49 a.m.
Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…

Follow us in social networks