Façade pattern
Encyclopedia
The facade pattern is a software engineering
design pattern
commonly used with Object-oriented programming
. The name is by analogy to an architectural facade
.
A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:
An Adapter
is used when the wrapper must respect a particular interface and must support a polymorphic behavior. On the other hand, a facade is used when one wants an easier or simpler interface to work with.
Facade
Clients
Software engineering
Software Engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software, and the study of these approaches; that is, the application of engineering to software...
design pattern
Design pattern (computer science)
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that...
commonly used with Object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
. The name is by analogy to an architectural facade
Facade
A facade or façade is generally one exterior side of a building, usually, but not always, the front. The word comes from the French language, literally meaning "frontage" or "face"....
.
A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:
- make a software library easier to use, understand and test, since the facade has convenient methods for common tasks;
- make code that uses the library more readable, for the same reason;
- reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system;
- wrap a poorly-designed collection of APIs with a single well-designed API (as per task needs).
An Adapter
Adapter pattern
In computer programming, the adapter pattern is a design pattern that translates one interface for a class into a compatible interface...
is used when the wrapper must respect a particular interface and must support a polymorphic behavior. On the other hand, a facade is used when one wants an easier or simpler interface to work with.
Structure
Facade
- The facade class abstracts Packages 1, 2, and 3 from the rest of the application.
Clients
- The objects using the Facade Pattern to access resources from the Packages.