Facade (design sample)
Facade ( english facade , even façade written) is a design pattern in the field of software development , which the category of structural patterns (engl. Structural design patterns ) belongs. It offers a uniform and mostly simplified interface to a number of interfaces of a subsystem .
When a subsystem contains many technically oriented classes that are seldom used externally, it helps to use a facade. The facade is a select method class that encompasses a frequently required subset of the functionality of the subsystem. It delegates the functionality to other classes of the subsystem and thereby simplifies the handling of the subsystem.
advantages and disadvantages
The facade promotes loose coupling because it hides the underlying subsystem and reduces complexity because several interfaces are combined into one. In addition, the subsystem can be expanded more easily due to the loose coupling.
The disadvantage is that an additional indirection stage is introduced.
example
The standard Java library contains a large number of classes for processing fonts and displaying them as geometric figures or directly as pixels. Nevertheless, most Java programmers never come to these classes in contact because the standard library with the facade classes Font
and Graphics
very easy access to the most important granted font operations.
structure
- Facade
- The facade. It refers to the classes Class1, Class2 and Class3.
- Clients
- The objects that use the facade.
Related design patterns
The Abstract Factory (Kit) can be used together with a facade to provide an interface for creating system objects independent of the subsystem.
The mediator (mediator) is exactly like the facade as a mediator between classes to avoid direct traffic.
The adapter (wrapper) provides a modified interface to an existing class or subsystem.
Business Delegate is the counterpart to the facade on the calling component.
literature
- Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: Design Pattern . Addison-Wesley Verlag, Munich 2004, ISBN 3-89319-950-0 .
- Bernd Brügge, Allen H. Dutoit: Object-oriented software technology: with UML, design patterns and Java - 2nd, revised edition , Addison-Wesley Verlag, 2004, ISBN 3-82737-082-5 .
Web links
- Beginner-friendly introduction to the Facade Design Pattern
- Report from the private University of Applied Sciences Wedel on the structural pattern facade
Individual evidence
- ↑ Erich Gamma , Richard Helm , Ralph Johnson , John Vlissides : Design pattern . 5th edition. Addison-Wesley , 1996, ISBN 3-8273-1862-9 , pp. 212 .