Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Facade pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Example == <!-- Wikipedia is not a list of examples. Do not add examples from your favorite programming language here; this page exists to explain the design pattern, not to show how it interacts with subtleties of every language under the sun. Feel free to add examples here: http://en.wikibooks.org/wiki/Computer_Science_Design_Patterns/Facade --> <!-- In this example the author has confused a facade with a class composed of other components that it uses. This should be rewritten. --> This is an abstract example of how a client ("you") interacts with a facade (the "computer") to a complex system (internal computer parts, like CPU and HardDrive). === C++ === <syntaxhighlight lang="c++"> struct CPU { void Freeze(); void Jump(long position); void Execute(); }; struct HardDrive { char* Read(long lba, int size); }; struct Memory { void Load(long position, char* data); }; class ComputerFacade { public: void Start() { cpu_.Freeze(); memory_.Load(kBootAddress, hard_drive_.Read(kBootSector, kSectorSize)); cpu_.Jump(kBootAddress); cpu_.Execute(); } private: CPU cpu_; Memory memory_; HardDrive hard_drive_; }; int main() { ComputerFacade computer; computer.Start(); } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)