2007-05-16
电话面试
今天接到电话面试,起先问的问题都还可以,之后问了我一个什么叫门面模式,我倒是用过模式,不过没用过门面模式,哪位大哥知道啊?
definiton:
为子系统中的多个接口提供一个统一的接口,Facade 定义了一个更高层的接口以方便子系统更方便的应用。

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();
}
}
}
Output
MethodA() ----
SubSystemOne Method
SubSystemTwo Method
SubSystemFour Method
MethodB() ----
SubSystemTwo Method
SubSystemThree Method
definiton:
为子系统中的多个接口提供一个统一的接口,Facade 定义了一个更高层的接口以方便子系统更方便的应用。
UML class diagram

sample code in C#
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();
}
}
}
Output
MethodA() ----
SubSystemOne Method
SubSystemTwo Method
SubSystemFour Method
MethodB() ----
SubSystemTwo Method
SubSystemThree Method
发表评论
- 浏览: 8398 次

- 详细资料
搜索本博客
最新评论
-
ActionController::Invali ...
不错,终于找到解决方案了.谢谢!
-- by qianjigui -
ActionController::Invali ...
是的,可以的,不过那样的话就全部disable了,这样只适合在的developm ...
-- by 小小龙猫 -
ActionController::Invali ...
也可以通过修改enviroment.rb来解决这个问题吧.
-- by xiuxiuxiu -
电话面试
Java与模式里面好像就是写门面模式
-- by lifangxing -
最近眼睛疼的厉害
周末了在家休息休息,眼药水现在天天滴了,如果还是疼的话就去医院看看。同志们多注意 ...
-- by 小小龙猫






评论排行榜