惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
GbyAI
GbyAI
B
Blog RSS Feed
H
Help Net Security
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Cloudflare Blog
Security Latest
Security Latest
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
P
Privacy & Cybersecurity Law Blog
J
Java Code Geeks
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threatpost
Schneier on Security
Schneier on Security
T
Tenable Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Latest news
Latest news
P
Proofpoint News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
G
GRAHAM CLULEY
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
博客园_首页
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threat Research - Cisco Blogs
T
Tor Project blog
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
月光博客
月光博客

博客园 - 李明飞

C#设计模式之我见(四)Ⅱ C#设计模式之我见(四)Ⅰ C#设计模式之我见(三)Ⅲ C#设计模式之我见(三)Ⅱ C#设计模式之我见(三)Ⅰ C#设计模式之我见(二)Ⅰ C#设计模式之我见(一) 面向对象编程之重用、继承、多态、抽象 初探SilverLight 2.0的安装和部署 工作小札,生活一杯羹! “管家婆”的好帮手——我的理财小管家 类库DLL属性说明和正确使用App_Code中类的静态成员 冬日糊辣汤 以前的面试题(二) 以前的面试题 SQL Server 2005新特性之感悟 招聘高级网页设计师(北京) 知识点滴(打油篇) Web Services 的设计和模式
C#设计模式之我见(二)Ⅱ
李明飞 · 2011-06-26 · via 博客园 - 李明飞

下面介绍一下建造者模式(Builder Pattern),代码实例如下:
Builder
public abstract class Builder
     {
          public abstract void BuildDoor();
          public abstract void BuildWall();
          public abstract void BuildWindows();
          public abstract void BuildFloor();
          public abstract void BuildHouseCeiling();
      
          public abstract House GetHouse();
     }

Director类:
public class Director
   {
      public void Construct(Builder builder)
       {
            builder.BuildWall();
            builder.BuildHouseCeiling();          
            builder.BuildDoor();
            builder.BuildWindows();
            builder.BuildFloor();         
       }
     }

ChineseBuilder类:
public class ChineseBuilder:Builder
      {
         private House ChineseHouse = new House();
          public override void BuildDoor()
          {
              Console.WriteLine("this Door 's style of Chinese");
          }
          public override void BuildWall()
          {
             Console.WriteLine("this Wall 's style of Chinese");
         }
         public override void BuildWindows()
         {
             Console.WriteLine("this Windows 's style of Chinese");
         }
         public override void BuildFloor()
         {
             Console.WriteLine("this Floor 's style of Chinese");
         }
         public override void BuildHouseCeiling()
         {
             Console.WriteLine("this Ceiling 's style of Chinese");
         }
         public override House GetHouse()
         {
             return ChineseHouse;
         }
     }

阅读全文

posted @ 2011-06-26 12:26  李明飞  阅读(376)  评论()    收藏  举报