Example
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).
/* Complex parts */ class CPU { public void freeze { ... } public void jump(long position) { ... } public void execute { ... } } class Memory { public void load(long position, byte data) { ... } } class HardDrive { public byte read(long lba, int size) { ... } } /* Facade */ class Computer { private CPU cpu; private Memory memory; private HardDrive hardDrive; public Computer { this.cpu = new CPU; this.memory = new Memory; this.hardDrive = new HardDrive; } public void startComputer { cpu.freeze; memory.load(BOOT_ADDRESS, hardDrive.read(BOOT_SECTOR, SECTOR_SIZE)); cpu.jump(BOOT_ADDRESS); cpu.execute; } } /* Client */ class You { public static void main(String args) { Computer facade = new Computer; facade.startComputer; } }Read more about this topic: Facade Pattern
Famous quotes containing the word example:
“Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.”
—Marcel Proust (18711922)