外觀模式(Facade),亦稱“過程模式”。學校課程評價模式之一。美國教育學者斯泰克1967 年在所著《教育評價的外觀》中提出。主張按照描述和判斷資料來評價課程,關鍵的活動是在課程實施的全過程中進行觀察和蒐集意見,以了解人們對課程的不同看法。這種模式不限於檢查教學的成果,重視描述和判斷教學過程中各種複雜、動態的現象和事物。
基本介紹
- 中文名:外觀模式
- 外文名:Facade
- 類型:組合型
- 學科:計算機
結構
適用場景
優點
示例
Java
/* 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) { ... }}/* Façade */class Computer { 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(); }}
C#
// Facade pattern -- Structural example using System;namespace DoFactory.GangOfFour.Facade.Structural{ // Mainapp test application class MainApp { public static void Main() { Facade facade = new Facade(); facade.MethodA(); facade.MethodB(); // Wait for user Console.Read(); } } // "Subsystem ClassA" class SubSystemOne { public void MethodOne() { Console.WriteLine(" SubSystemOne Method"); } } // Subsystem ClassB" class SubSystemTwo { public void MethodTwo() { Console.WriteLine(" SubSystemTwo Method"); } } // Subsystem ClassC" class SubSystemThree { public void MethodThree() { Console.WriteLine(" SubSystemThree Method"); } } // Subsystem ClassD" class SubSystemFour { public void MethodFour() { Console.WriteLine(" SubSystemFour Method"); } } // "Facade" class Facade { SubSystemOne one; SubSystemTwo two; SubSystemThree three; SubSystemFour four; public Facade() { one = new SubSystemOne(); two = new SubSystemTwo(); three = new SubSystemThree(); four = new SubSystemFour(); } public void MethodA() { Console.WriteLine("\nMethodA() ---- "); one.MethodOne(); two.MethodTwo(); four.MethodFour(); } public void MethodB() { Console.WriteLine("\nMethodB() ---- "); two.MethodTwo(); three.MethodThree(); } }}