亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pat4c.htm

?? java設計范式.rar
?? HTM
?? 第 1 頁 / 共 2 頁
字號:
<SCRIPT>
function setFocus() {	
	if ((navigator.appName != "Netscape") && (parseFloat(navigator.appVersion) == 2)) {
	return;
	} else {
	self.focus();
	}
}
</SCRIPT><HTML><HEAD><TITLE>Composite</TITLE><SCRIPT>function setFocus() {		if ((navigator.appName != "Netscape") && (parseFloat(navigator.appVersion) == 2)) {	return;	} else {	self.focus();	}}</SCRIPT></HEAD><BODY	BGCOLOR	= #FFFFFF	TEXT = #000000
onLoad="setFocus()";onLoad="setFocus()";><A NAME="top"></A><A NAME="Composite"></A><A NAME="intent"></A><H2><A HREF="#motivation"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Motivation"></A> Intent</H2> <A NAME="auto1000"></A><P>Compose objects into tree structures to represent part-wholehierarchies.  Composite lets clients treat individual objects andcompositions of objects uniformly.</P><A NAME="motivation"></A><H2><A HREF="#applicability"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Applicability"></A> Motivation</H2> <A NAME="auto1001"></A><P>Graphics applications like drawing editors and schematic capturesystems let users build complex diagrams out of simple components.The user can group components to form larger components, which inturn can be grouped to form still larger components.  A simpleimplementation could define classes for graphical primitives suchas Text and Lines plus other classes that act as containers forthese primitives.</P><A NAME="recursivecomp-graphics"></A><P>But there's a problem with this approach:  Code that uses theseclasses must treat primitive and container objects differently,even if most of the time the user treats them identically.  Havingto distinguish these objects makes the application more complex.The Composite pattern describes how to use recursive compositionso that clients don't have to make this distinction.</P><A NAME="picture-163c"></A><P ALIGN=CENTER><IMG SRC="Pictures/compo075.gif"></P><A NAME="auto1002"></A><P>The key to the Composite pattern is an abstract class thatrepresents <EM>both</EM> primitives and their containers.  For thegraphics system, this class is Graphic.  Graphic declares operationslike Draw that are specific to graphical objects.  It also declaresoperations that all composite objects share, such as operationsfor accessing and managing its children.</P><A NAME="auto1003"></A><P>The subclasses Line, Rectangle, and Text (see preceding class diagram)define primitive graphical objects.  These classes implement Draw todraw lines, rectangles, and text, respectively.  Since primitivegraphics have no child graphics, none of these subclasses implementschild-related operations.</P><A NAME="auto1004"></A><P>The Picture class defines an aggregate of Graphic objects.  Pictureimplements Draw to call Draw on its children, and it implementschild-related operations accordingly.  Because the Picture interfaceconforms to the Graphic interface, Picture objects can compose otherPictures recursively.</P><A NAME="auto1005"></A><P>The following diagram shows a typical composite object structureof recursively composed Graphic objects:</P><A NAME="picture-164o"></A><P ALIGN=CENTER><IMG SRC="Pictures/compo074.gif"></P><A NAME="applicability"></A><H2><A HREF="#structure"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Structure"></A> Applicability</H2> <A NAME="auto1006"></A><P>Use the Composite pattern when</P><UL><A NAME="auto1007"></A><LI>you want to represent part-whole hierarchies of objects.<A NAME="auto1008"></A><P></P><A NAME="auto1009"></A><LI>you want clients to be able to ignore the difference betweencompositions of objects and individual objects. Clients will treat allobjects in the composite structure uniformly.</UL><A NAME="structure"></A><H2><A HREF="#participants"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Participants"></A> Structure</H2> <P ALIGN=CENTER><IMG SRC="Pictures/compo072.gif"></P><A NAME="auto1010"></A><P>A typical Composite object structure might look like this:</P><A NAME="composite-inst"></A><P ALIGN=CENTER><IMG SRC="Pictures/compo073.gif"></P><A NAME="participants"></A><H2><A HREF="#collaborations"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Collaborations"></A> Participants</H2><UL><A NAME="auto1011"></A><LI><B>Component</B> (Graphic)<A NAME="auto1012"></A><P></P>    <UL>    <A NAME="auto1013"></A><LI>declares the interface for objects in the composition.</LI>    <A NAME="auto1014"></A><P><!-- extra space --></P>    <A NAME="auto1015"></A><LI>implements default behavior for the interface    common to all classes, as appropriate.</LI>    <A NAME="auto1016"></A><P><!-- extra space --></P>    <A NAME="auto1017"></A><LI>declares an interface for accessing and managing its child    components.</LI>    <A NAME="auto1018"></A><P><!-- extra space --></P>    <A NAME="auto1019"></A><LI>(optional) defines an interface for accessing a component's    parent in the recursive structure, and implements it if that's    appropriate.</LI>    </UL><A NAME="auto1020"></A><P></P><A NAME="leaf-part-comp"></A><LI><B>Leaf</B> (Rectangle, Line, Text, etc.)<A NAME="auto1021"></A><P></P>    <UL>    <A NAME="auto1022"></A><LI>represents leaf objects in the composition. A leaf has no    children.</LI>    <A NAME="auto1023"></A><P><!-- extra space --></P>    <A NAME="auto1024"></A><LI>defines behavior for primitive objects in the composition.</LI>    </UL><A NAME="auto1025"></A><P></P><A NAME="auto1026"></A><LI><B>Composite</B> (Picture)<A NAME="auto1027"></A><P></P>    <UL>    <A NAME="auto1028"></A><LI>defines behavior for components having children.</LI>    <A NAME="auto1029"></A><P><!-- extra space --></P>    <A NAME="auto1030"></A><LI>stores child components.</LI>    <A NAME="auto1031"></A><P><!-- extra space --></P>    <A NAME="auto1032"></A><LI>implements child-related operations in the Component interface.</LI>    </UL><A NAME="auto1033"></A><P></P><A NAME="auto1034"></A><LI><B>Client</B><A NAME="auto1035"></A><P></P>    <UL>    <A NAME="auto1036"></A><LI>manipulates objects in the composition through the    Component interface.</LI>    </UL></UL><A NAME="collaborations"></A><H2><A HREF="#consequences"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Consequences"></A> Collaborations</H2><UL><A NAME="auto1037"></A><LI>Clients use the Component class interface to interact with objects inthe composite structure. If the recipient is a Leaf, then the requestis handled directly.  If the recipient is a Composite, then it usuallyforwards requests to its child components, possibly performingadditional operations before and/or after forwarding.</LI></UL><A NAME="consequences"></A><H2><A HREF="#implementation"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Implementation"></A> Consequences</H2> <A NAME="auto1038"></A><P>The Composite pattern</P><UL><A NAME="auto1039"></A><LI>defines class hierarchies consisting of primitive objectsand composite objects. Primitive objects can be composed into morecomplex objects, which in turn can be composed, and so on recursively.Wherever client code expects a primitive object, it can also take acomposite object.</LI><A NAME="auto1040"></A><P></P><A NAME="auto1041"></A><LI>makes the client simple.Clients can treat composite structures and individual objectsuniformly.  Clients normally don't know (and shouldn't care) whetherthey're dealing with a leaf or a composite component.  This simplifiesclient code, because it avoids having to writetag-and-case-statement-style functions over the classes that definethe composition.</LI><A NAME="auto1042"></A><P></P><A NAME="auto1043"></A><LI>makes it easier to add new kinds of components.Newly defined Composite or Leaf subclasses work automatically withexisting structures and client code.  Clients don't have to be changedfor new Component classes.</LI><A NAME="auto1044"></A><P></P><A NAME="auto1045"></A><LI>can make your design overly general.The disadvantage of making it easy to add new components is that itmakes it harder to restrict the components of a composite.  Sometimesyou want a composite to have only certain components.  WithComposite, you can't rely on the type system to enforce thoseconstraints for you.  You'll have to use run-time checks instead.</LI></UL><A NAME="implementation"></A><H2><A HREF="#samplecode"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Sample Code"></A> Implementation</H2> <A NAME="auto1046"></A><P>There are many issues to consider when implementing the Compositepattern:</P><OL><A NAME="parentref-def-comp"></A><LI><EM>Explicit parent references.</EM>Maintaining references from child components to their parent cansimplify the traversal and management of a composite structure.  Theparent reference simplifies moving up the structure and deleting acomponent. Parent references also help support the <A HREF="pat5afs.htm" TARGET="_mainDisplayFrame">Chain of Responsibility (223)</A> pattern.<A NAME="auto1047"></A><P>The usual place to define the parent reference is in the Componentclass.  Leaf and Composite classes can inherit the reference and theoperations that manage it.</P><A NAME="auto1048"></A><P>With parent references, it's essential to maintain the invariant thatall children of a composite have as their parent the composite that inturn has them as children.  The easiest way to ensure this is tochange a component's parent <EM>only</EM> when it's being added orremoved from a composite.  If this can be implemented once in the Addand Remove operations of the Composite class, then it can be inheritedby all the subclasses, and the invariant will be maintainedautomatically.</P></LI><A NAME="auto1049"></A><P></P><A NAME="auto1050"></A><LI><EM>Sharing components.</EM>It's often useful to share components, for example, to reduce storagerequirements. But when a component can have no more than one parent,sharing components becomes difficult.<A NAME="flywt-w-compst"></A><P>A possible solution is for children to store multiple parents.  Butthat can lead to ambiguities as a request propagates up the structure.The<A HREF="pat4ffs.htm" TARGET="_mainDisplayFrame">Flyweight (195)</A> pattern shows how to rework adesign to avoid storing parents altogether.  It works in cases wherechildren can avoid sending parent requests by externalizing some orall of their state.</P></LI><A NAME="auto1051"></A><P></P><A NAME="auto1052"></A><LI><EM>Maximizing the Component interface.</EM>One of the goals of the Composite pattern is to make clients unawareof the specific Leaf or Composite classes they're using.  To attainthis goal, the Component class should define as many common operationsfor Composite and Leaf classes as possible. The Component classusually provides default implementations for these operations, andLeaf and Composite subclasses will override them.<A NAME="auto1053"></A><P>However, this goal will sometimes conflict with the principle of classhierarchy design that says a class should only define operations thatare meaningful to its subclasses.  There are many operations thatComponent supports that don't seem to make sense for Leaf classes.How can Component provide a default implementation for them?</P><A NAME="auto1054"></A><P>Sometimes a little creativity shows how an operation that would appearto make sense only for Composites can be implemented for allComponents by moving it to the Component class.  For example, theinterface for accessing children is a fundamental part of a Compositeclass but not necessarily Leaf classes.  But if we view a Leaf as aComponent that <EM>never</EM> has children, then we can define a defaultoperation for child access in the Component class that never <EM>returns</EM> any children.  Leaf classes can use the defaultimplementation, but Composite classes will reimplement it to returntheir children.</P><A NAME="auto1055"></A><P>The child management operations are more troublesome and are discussedin the next item.</P></LI><A NAME="auto1056"></A><P></P><A NAME="auto1057"></A><LI><EM>Declaring the child management operations.</EM>Although the Composite class <EM>implements</EM> the Add and Removeoperations for managing children, an important issue in the Compositepattern is which classes <EM>declare</EM> these operations in theComposite class hierarchy.  Should we declare these operations in theComponent and make them meaningful for Leaf classes, or should wedeclare and define them only in Composite and its subclasses?<A NAME="auto1058"></A><P>The decision involves a trade-off between safety and transparency:</P><UL><A NAME="auto1059"></A><LI>Defining the child management interface at the root of the classhierarchy gives you transparency, because you can treat all componentsuniformly.  It costs you safety, however, because clients may try todo meaningless things like add and remove objects from leaves.</LI><A NAME="auto1060"></A><P></P><A NAME="auto1061"></A><LI>Defining child management in the Composite class gives you safety,because any attempt to add or remove objects from leaves will becaught at compile-time in a statically typed language like C++.  Butyou lose transparency, because leaves and composites have differentinterfaces.</LI></UL><A NAME="auto1062"></A><P>We have emphasized transparency over safety in this pattern.  If youopt for safety, then at times you may lose type information and haveto convert a component into a composite.  How can you do this withoutresorting to a type-unsafe cast?</P><A NAME="leaf-in-comp"></A><P>One approach is to declare an operation <CODE>Composite*GetComposite()</CODE> in the Component class.  Component provides a defaultoperation that returns a null pointer.  The Composite class redefinesthis operation to return itself through the <CODE>this</CODE> pointer:</P><A NAME="auto1063"></A><PRE>    class Composite;    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃一区二区三区四区| 看片的网站亚洲| 欧美浪妇xxxx高跟鞋交| 91精品国产高清一区二区三区蜜臀 | 国产精品久久久久久福利一牛影视| 久久久综合视频| 国产精品国产三级国产三级人妇| 亚洲黄色片在线观看| 国产在线视频一区二区三区| 国产精品白丝jk黑袜喷水| 538在线一区二区精品国产| 久久久久国产精品人| 亚洲在线观看免费| 99久久婷婷国产综合精品电影| 7878成人国产在线观看| 中文字幕一区二区三区在线播放| 成人av电影免费在线播放| 国产成人丝袜美腿| 欧美影院一区二区| 精品国产sm最大网站免费看| 一区二区三区高清不卡| 国产精品亚洲一区二区三区在线| 欧美一区二区三区在线视频| 日韩vs国产vs欧美| 一本大道av一区二区在线播放| 日韩精品在线网站| 日韩精品久久理论片| 色av综合在线| 久久你懂得1024| 国产成人精品影视| 久久一夜天堂av一区二区三区| 日本人妖一区二区| 欧美精品一区二区在线观看| 午夜电影网亚洲视频| 国产一区二区主播在线| 日韩一区二区三区电影在线观看| 久久久精品影视| 悠悠色在线精品| 欧美午夜电影一区| 亚洲国产视频在线| 欧美少妇性性性| 日本系列欧美系列| 日韩欧美国产三级电影视频| 免费国产亚洲视频| 奇米影视7777精品一区二区| 日韩一二三区不卡| 免费观看日韩电影| 日韩一区二区在线观看视频 | 日韩精彩视频在线观看| 欧美三级日韩三级| 亚洲一卡二卡三卡四卡 | 亚洲图片欧美一区| 麻豆视频观看网址久久| 欧美电影免费观看高清完整版在| 日韩黄色小视频| 欧美老肥妇做.爰bbww| 久草这里只有精品视频| 久久久三级国产网站| 欧美不卡在线视频| 丁香六月综合激情| 亚洲色图欧美在线| 91亚洲精品一区二区乱码| 国产精品黄色在线观看| 日本电影欧美片| 亚洲国产精品二十页| 一本大道久久a久久综合婷婷| 亚洲欧美另类图片小说| 欧美卡1卡2卡| 国产麻豆视频一区二区| 亚洲日本va午夜在线影院| 色综合视频在线观看| 老色鬼精品视频在线观看播放| 国产欧美日韩综合精品一区二区 | 日韩专区欧美专区| 欧美三区免费完整视频在线观看| 全国精品久久少妇| 中文字幕欧美日韩一区| 欧美专区在线观看一区| 一区二区在线免费| 国产视频911| 欧美日韩中文字幕一区二区| 久久99精品久久久久久国产越南| 精品久久国产字幕高潮| eeuss鲁片一区二区三区| 亚洲综合一区二区精品导航| 日韩欧美国产wwwww| 欧美三级日韩三级国产三级| 国产成人在线视频网站| 天堂一区二区在线免费观看| 国产精品传媒入口麻豆| 欧美v亚洲v综合ⅴ国产v| 91在线播放网址| 日韩二区三区四区| 亚洲国产美女搞黄色| 国产日产亚洲精品系列| 91麻豆精品国产综合久久久久久| 日韩精品午夜视频| 亚洲国产高清不卡| 中文字幕一区二区三区在线不卡 | 26uuu另类欧美| 91精品在线免费观看| 色94色欧美sute亚洲线路二 | 欧美系列亚洲系列| 精品一区二区三区av| 久久99国产乱子伦精品免费| 亚洲综合色噜噜狠狠| 国产精品免费视频一区| 91精品国产综合久久精品| 91在线播放网址| 成人av网址在线| 国产精品18久久久久久久网站| 蜜桃av一区二区| 午夜视频在线观看一区二区| 国产精品久久99| 久久久久久**毛片大全| 精品国产乱码久久久久久影片| 欧美放荡的少妇| 欧美日韩一区二区在线观看 | 香蕉成人伊视频在线观看| 亚洲精品视频在线观看免费| 国产精品久久久久久久岛一牛影视 | 福利一区二区在线观看| 国产成人精品aa毛片| 国产在线精品视频| 国产毛片一区二区| 日韩高清不卡一区二区三区| 亚洲第四色夜色| 亚洲一区二区影院| 久久一区二区三区四区| 国产精品乱码人人做人人爱| 日本不卡一区二区三区| 国产精品白丝在线| 中文字幕中文乱码欧美一区二区| 精品福利视频一区二区三区| 欧美激情综合五月色丁香| 自拍偷拍亚洲激情| 亚洲国产综合人成综合网站| 美腿丝袜亚洲综合| 国产成人精品aa毛片| 成人av资源在线观看| 欧美在线观看18| 精品粉嫩超白一线天av| 中文字幕在线不卡一区| 亚洲va天堂va国产va久| 国产成人免费av在线| 91亚洲精品乱码久久久久久蜜桃| 欧美日韩一区在线| 国产午夜亚洲精品理论片色戒 | 美女mm1313爽爽久久久蜜臀| 狠狠狠色丁香婷婷综合激情 | 国产老肥熟一区二区三区| gogogo免费视频观看亚洲一| 欧美绝品在线观看成人午夜影视| 欧美成人欧美edvon| 亚洲人被黑人高潮完整版| 青青青伊人色综合久久| av成人免费在线观看| 日韩一区二区在线播放| 中文字幕一区二区三区色视频| 日韩精品久久理论片| 色综合天天狠狠| 久久精品一区二区三区四区| 午夜成人免费电影| 成人av影院在线| 久久久久久久久久久久久久久99 | 一区二区三区日韩在线观看| 国产一区二区日韩精品| 91精品在线免费观看| 亚洲乱码日产精品bd| 国产精品一区二区三区乱码| 欧美一区二区播放| 亚洲自拍偷拍网站| 99久久精品免费精品国产| 26uuuu精品一区二区| 三级一区在线视频先锋| 色悠悠久久综合| 国产精品美女久久久久久| 国产精品一级二级三级| 日韩一级二级三级精品视频| 亚洲国产欧美日韩另类综合| 91猫先生在线| 亚洲欧美日韩小说| 93久久精品日日躁夜夜躁欧美| 久久亚洲一级片| 精品一区二区三区免费毛片爱| 3atv一区二区三区| 亚洲成人你懂的| 欧美系列在线观看| 亚洲影视在线播放| 欧美三级欧美一级| 亚洲福利视频三区| 欧美人与禽zozo性伦| 亚洲va韩国va欧美va| 欧美欧美欧美欧美| 视频一区二区中文字幕| 91精品久久久久久久99蜜桃 | 亚洲国产日日夜夜| 欧美日本一道本| 老司机一区二区| 精品日韩成人av|