﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-春暖花开-随笔分类-设计模式</title><link>http://www.cppblog.com/SpringSnow/category/11041.html</link><description>雪化了，花开了，春天来了</description><language>zh-cn</language><lastBuildDate>Wed, 22 Jul 2009 03:50:16 GMT</lastBuildDate><pubDate>Wed, 22 Jul 2009 03:50:16 GMT</pubDate><ttl>60</ttl><item><title>设计模式学习笔记</title><link>http://www.cppblog.com/SpringSnow/archive/2009/07/21/90752.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 21 Jul 2009 10:11:00 GMT</pubDate><guid>http://www.cppblog.com/SpringSnow/archive/2009/07/21/90752.html</guid><wfw:comment>http://www.cppblog.com/SpringSnow/comments/90752.html</wfw:comment><comments>http://www.cppblog.com/SpringSnow/archive/2009/07/21/90752.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/SpringSnow/comments/commentRss/90752.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/SpringSnow/services/trackbacks/90752.html</trackback:ping><description><![CDATA[<h3 style="MARGIN: 13pt 0cm; TEXT-ALIGN: center" align=center><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size=5>设计模式学习笔记</font></span></h3>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最近利用早晨的大好时光，学习了一下设计模式，同时学习了英语。目前一共学习了八种模式：</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">一、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Observer Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It defines a one to many relationship between a set of objects. When the state of one object changes, all of its dependents are notified.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">二、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Decorator Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It attaches additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">三、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Factory Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclass.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">四、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Abstract Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It provides an interface for creating families of related or dependent objects without specifying their concrete classes.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">五、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Singleton Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It ensures a class has only one instance, and provides a global point of access to it.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">六、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Command Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">七、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Adapter Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn&#8217;t otherwise because of <span style="mso-spacerun: yes">&nbsp;</span>imcompatible interface.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US style="mso-bidi-font-family: 宋体"><span style="mso-list: Ignore">八、<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span></strong><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>The Fa&#231;ade Pattern<o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US>It provides a unified interface to a set of interfaces in a subsystem. Fa&#231;ade defines a higher-level interface that makes the subsystem easier to use.</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p>&nbsp;</o:p></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在这上述的八个模式中</span><span lang=EN-US>,</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">包含了设计模式的三种类型：创建型模式，结构型模式，行为模式。其中</span><span lang=EN-US>Factory</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US>Abstract Factory</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US>Singleton</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为创建型模式，</span><span lang=EN-US>Decorator</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US>Adapter</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US>Facade</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为结构型模式，其余的</span><span lang=EN-US>Command</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang=EN-US>Observer</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为行为模式。</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不过，感觉有时侯理解的特别清楚，但过一段时间就忘了。所以一定要将其用起来，才能对其有深深的体会，不会就是死的知识。一定要让其活起来。</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">呵呵，又看了一些蜗牛的家写的设计模式趣解，反而更有助于理解呦，不妨看看。链接地址为：</span><span lang=EN-US>http://www.cppblog.com/bangle/archive/<st1:chsdate w:st="on" IsROCDate="False" IsLunarDate="False" Day="23" Month="8" Year="2008">2008/08/23</st1:chsdate>/59725.html</span></p>
<img src ="http://www.cppblog.com/SpringSnow/aggbug/90752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/SpringSnow/" target="_blank">Sandy</a> 2009-07-21 18:11 <a href="http://www.cppblog.com/SpringSnow/archive/2009/07/21/90752.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>好好学模式</title><link>http://www.cppblog.com/SpringSnow/archive/2009/06/29/88805.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Mon, 29 Jun 2009 10:48:00 GMT</pubDate><guid>http://www.cppblog.com/SpringSnow/archive/2009/06/29/88805.html</guid><wfw:comment>http://www.cppblog.com/SpringSnow/comments/88805.html</wfw:comment><comments>http://www.cppblog.com/SpringSnow/archive/2009/06/29/88805.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/SpringSnow/comments/commentRss/88805.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/SpringSnow/services/trackbacks/88805.html</trackback:ping><description><![CDATA[以前看过很多关于设计模式的书籍，但是没怎么用过，都想过眼烟云一般，烟消云散了，在我的脑海里无影无踪了。<br>近期有开始看起，想想这方面还是蛮重要的，抱着HeadFirst看起来了，不过是影印版，也权当一块练英语了。加油！<br><br>发现，如果不写出来，知识摆在那里依旧是死的知识，不能活跃在自己的脑海里。所以借此一角，发发我的小感知。
<img src ="http://www.cppblog.com/SpringSnow/aggbug/88805.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/SpringSnow/" target="_blank">Sandy</a> 2009-06-29 18:48 <a href="http://www.cppblog.com/SpringSnow/archive/2009/06/29/88805.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>