Facade pattern
|
In computer programming, 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 and understand, 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.
The facade is an object-oriented design pattern.
Facades are very common in object-oriented design. For example, the Java standard library contains dozens of classes for parsing font files and rendering text into geometric outlines and ultimately into pixels. However, most Java programmers are unaware of these details, because the library also contains facade classes (Font
and Graphics
- Graphics
itself is wrapped by another class Graphics2D
offering more functionality) that offer simple methods for the most common font-related operations.
See also
External links
- Description from the Portland Pattern Repository (http://c2.com/cgi/wiki?FacadePattern)
- Description (http://home.earthlink.net/~huston2/dp/facade.html) by Vince Hustonde:Fassade (Entwurfsmuster)