锘??xml version="1.0" encoding="utf-8" standalone="yes"?> Me and my wife had some interesting conversations on Object Oriented Design principles. After publishing the conversation on CodeProject, I got some good responses from the community and that really inspired me. So, I am happy to share our next conversation that took place on Object Oriented Design Patterns. Here it is. Shubho: I guess you already have some basic idea about Object Oriented Design principles. We had a nice talk on the OOD principles (SOLID principles), and I hope you didn't mind that I published our conversation in a CodeProject article. You can find it here: How I explained OOD to my wife. Design Patterns are nothing but applications of those principles in some specific and common situations, and standardizing some of those. Let's try to understand what Design Patterns are by using some examples. Farhana: Sure, I love examples. Shubho: Let's talk about our car. It's an object, though a complex one, which consists of thousands of other objects such as the engine, wheels, steering, seats, body, and thousands of different parts and machinery. While building this car, the manufacturer gathered and assembled all the different smaller parts that are subsystems of the car. These different smaller parts are also some complex objects, and some other manufacturers had to build and assemble those too. But, while building the car, the car company doesn't really bother too much about how those objects were built and assembled (well, as long as they are sure about the quality of these smaller objects/equipments). Rather, the car manufacturer cares about how to assemble those different objects into different combinations and produce different models of cars. Farhana: The car manufacturer company must have some designs or blue prints for each different model of car which they follow, right? Shubho: Definitely, and, these designs are well-thought designs, and they've put a good amount of time and effort to sketch those designs. Once the designs are finalized, producing a car is just a matter of following the designs. Farhana: Hm.. it's good to have some good designs upfront and following those allows to produce different products in a quick amount of time, and each time the manufacturer has to build a product for a specific model, they don't have to develop a design from scratch or re-invent the wheel, they just follow the designs. Shubho: You got the point. Now, we are software manufacturers and we build different kinds of software programs with different components or functionality based upon the requirements. While building such different software systems, we often have to develop code for some situations that are common in many different software systems, right? Farhana: Yes. And often, we face common design problems while developing different software applications. Shubho: We try to develop our software applications in an Object Oriented manner and try to apply OOD principles for achieving code that is manageable, reusable, and expandable. Wouldn't it be nice whenever we see such design problems, we have a pool of some carefully made and well tested designs of objects for solving those? Farhana: Yes, that would save us time and would also allow us to build better software systems and manage them later. Shubho: Perfect. The good news is, you don't have to really develop that pool of object designs from scratch. People already have gone through similar design problems for years, and they already have identified some good design solutions which have been standardized already. We call these Design Patterns. We must thank the Gang of Four (GoF) for identifying the 23 basic Design Patterns in their book Design Patterns: Elements of Reusable Object-Oriented Software. In case you are wondering who formed this famous gang, they are Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. There are many Object Oriented Design Patterns, but these 23 patterns are generally considered the foundation for all other Design Patterns. Farhana: Can I create a new pattern? Is that possible? Shubho: Yes darling, why not? Design Patterns are not something invented or newly created by scientists. They are just discovered. That means, for each kind of common problem scenario, there must be some good design solutions there. If we are able to identify an object oriented design that could solve a new design related problem, that would be a new Design Pattern defined by us. Who knows? If we discover some a Design Pattern, someday people may call us Gang of Two.. Ha ha. Fahana: :) Shubho: As I have always believed, examples are the greatest way of learning. In our learning approach, we won't discuss the theories first and implement later. I think this is a BAD approach. Design Patterns were not invented based on theories. Rather, the problem situations occurred first and based upon the requirement and context, some design solutions were evolved, and later some of them were standardized as patterns. So, for each design pattern we discuss, we will try to understand and analyze some real life example problems, and then we will try to formulate a design in a step by step process and end up with a design that will match with some patterns; Design Patterns were discovered in this same process. What do you think? Farhana: I think this approach makes more sense to me. If I can end up with Design Patterns by analyzing problems and formulating solutions, I won't have to memorize design diagrams and definitions. Please proceed using your approach. Shubho: Let's consider the following scenario: Our room has some electric equipments (lights, fans etc). The equipments are arranged in a way where they could be controlled by switches. At any time, you can replace or troubleshoot an electrical equipment without touching the other things. For example, you can replace a light with another without replacing or changing the switch. Also, you can replace a switch or troubleshoot it without touching or changing the corresponding light or fan; you can even connect the light with the fan's switch and connect the fan with the light's switch, without touching the switches. Farhana: Yes, but that's natural, right? Shubho: Yes, that's very natural, and that's how the arrangement should be. When different things are connected together, they should be connected in a way where change or replacement of one system doesn't affect another, or even if there is any effect, it stays minimal. This allows you to manage your system easily and at low cost. Just imagine if changing the light in your room requires you to change the switch also. Would you care to purchase and set up such a system in your house? Farhana: Definitely no. Shubho: Now, let's think how the lights or fans are connected with the switches so that changing one doesn't have any impact on the other. What do you think? Farhana: The wire, of course! Shubho: Perfect. It's the wire and the electrical arrangement that connect the lights/fans with the switches. We can generalize it as a bridge between the different systems that can get connected through it. The basic idea is, things shouldn't be directly connected with one another. Rather, they should be connected though some bridges or interfaces. That's what we call "loose coupling" in software world. Farhana: I see. I got the idea. Shubho: Now, let's try to understand some key issues in the light/fan and switch analogy, and try to understand how they are designed and connected. Farhana: OK, let me try. We have switches in our example. There may be some specific kinds of switches like normal switches, fancy ones, but, in general, they are switches. And, each switch can be turned on and off. So, we will have a base And, as we may have some specific kinds of switches, for example a fancy switch, a normal switch etc., we will also have These two specific switch classes may have their own specific features and behaviours, but for now, let's keep them simple. Shubho: Cool. Now, what about fan and light? Farhana: Let me try. I learned from the Open Closed principles from Object Oriented Design principles that we should try to do abstractions whenever possible, right? Shubho: Right. Farhana: Unlike switches, fan and light are two different things. For switches, we were able to use a base Shubho: Right. Farhana: OK, each electrical equipment has some common functionality. They could all be turned on or off. So the interface may be as follows: Shubho: Great. You are getting good at abstracting things. Now, we need a bridge. In real world, the wires are the bridges. But, in our object design, a switch knows how to turn on or off an electrical equipment, and the electrical equipment somehow needs to be connected with the switches, As we don't have any wire here, the only way to let the electrical equipment be connected with the switch is encapsulation. Farhana: Yes, but switches don't know the fans or lights directly. A switch actually knows about an electrical equipment Shubho: Right. Here, the encapsulated instance, which is an abstraction of fan or light ( Farhana: Understood. Let me try to define the actual electrical equipments, the fan and the light. As I see, these are electrical equipments in general, so these would simply implement the Following is the And, the Shubho: Great. Now, let's make switches work. The switches should have the ability inside them to turn on and turn off the electrical equipment (it is connected to) when the switch is turned on and off. These are the key issues: Basically, following is what we want to achieve: Farhana: I got it. So, the Shubho: Great work. Now, this certainly allows you to plug a fan from one switch to another. But you see, the opposite should also work. That means, you can change the switch of a fan or light without touching the fan or light. For example, you can easily change the switch of the light from So, you see, you can vary both the switches and the electrical equipments without any effect on the other, and connecting an abstraction of the electrical equipment with a switch (via encapsulation) is letting you do that. This design looks elegant and good. The Gang of Four has named this a pattern: The Bridge Pattern. Farhana: Cool. I think I've understood the idea. Basically, two systems shouldn't be connected or dependent on another directly. Rather, they should be connected or dependent via abstraction (as the Dependency Inversion principle and the Open-Closed principle say) so that they are loosely coupled, and thus we are able to change our implementation when required without much effect on the other part of the system. Shubho: You got it perfect darling. Let's see how the Bridge Pattern is defined: You will see that our design perfectly matches the definition. If you have a class designer (in Visual Studio, you can do that, and other modern IDEs should also support this feature), you will see that you have a class diagram similar to the following: Here, Abstraction is the base Farhana: Let me ask you a question, just curious. There are many other patterns as you said, why did you start with the Bridge pattern? Any important reason? Shubho: A very good question. Yes, I started with the Bridge pattern and not any other pattern (unlike many others) because of a reason. I believe the Bridge pattern is the base of all Object Oriented Design Patterns. You see: Farhana: Do you think I have understood it correctly? Shubho: I think you have understood it perfectly darling. Farhana: So, what's next? Shubho: By understanding the Bridge pattern, we have just started to understand the concepts of Design Patterns. In our next conversation, we would learn other Design Patterns, and I hope you won't get bored learning them. Farhana: I won't. Believe me.Introduction
What is a Design Pattern?










How will we learn Design Patterns?
A basic design problem and its solution




Switch class as follows:
Collapsepublic class Switch
{
public void On()
{
//Switch has an on button
}
public void Off()
{
//Switch has an off button
}
}
FancySwitch and NormalSwitch classes extending the Switch class:
Collapsepublic class NormalSwitch : Switch
{
}
public class FancySwitch : Switch
{
}
Switch class, but as fan and light are two different things, instead of defining a base class, an interface might be more appropriate. In general, they are all electrical equipments. So, we can define an interface, say,IElectricalEquipment, for abstracting fans and lights, right?
Collapsepublic interface IElectricalEquipment
{
void PowerOn(); //Each electrical equipment can be turned on
void PowerOff(); //Each electrical equipment can be turned off
}
IElectricalEquipment that it can turn on or off. So, that means, an ISwitch should have anIElectricalEquipment instance, right?IElectricalEquipment) is the bridge. So, let's modify the Switch class to encapsulate an electrical equipment:
Collapsepublic class Switch
{
public IElectricalEquipment equipment
{
get;
set;
}
public void On()
{
//Switch has an on button
}
public void Off()
{
//Switch has an off button
}
}
IElectricalEquipmentinterface.Fan class:
Collapsepublic class Fan : IElectricalEquipment
{
public void PowerOn()
{
Console.WriteLine("Fan is on");
}
public void PowerOff()
{
Console.WriteLine("Fan is off");
}
}
Fan class would be as follows:
Collapsepublic class Light : IElectricalEquipment
{
public void PowerOn()
{
Console.WriteLine("Light is on");
}
public void PowerOff()
{
Console.WriteLine("Light is off");
}
}
Collapsestatic void Main(string[] args)
{
//We have some electrical equipments, say Fan, Light etc.
//So, lets create them first.
IElectricalEquipment fan = new Fan();
IElectricalEquipment light = new Light();
//We also have some switches. Lets create them too.
Switch fancySwitch = new FancySwitch();
Switch normalSwitch = new NormalSwitch();
//Lets connect the Fan to the fancy switch
fancySwitch.equipment = fan;
//As the switch now has an equipment (Fan),
//so switching on or off should
//turn on or off the electrical equipment
fancySwitch.On(); //It should turn on the Fan.
//so, inside the On() method of Switch,
//we must turn on the electrical equipment.
//It should turn off the Fan. So, inside the On() method of
fancySwitch.Off();
//Switch, we must turn off the electrical equipment
//Now, lets plug the light to the fancy switch
fancySwitch.equipment = light;
fancySwitch.On(); //It should turn on the Light now
fancySwitch.Off(); //It should be turn off the Light now
}
On() method of the actual switches should internally call the TurnOn() method of the electrical equipment, and the Off() should call the TurnOff() method on the equipment. So, the Switchclass should be as follows:
Collapsepublic class Switch
{
public void On()
{
Console.WriteLine("Switch on the equipment");
equipment.PowerOn();
}
public void Off()
{
Console.WriteLine("Switch off the equipment");
equipment.PowerOff();
}
}
FancySwitch to NormalSwitch as follows:
CollapsenormalSwitch .equipment = light;
normalSwitch.On(); //It should turn on the Light now
normalSwitch.Off(); //It should be turn off the Light now
"Decouple an abstraction from its implementation so that the two can vary independently"

Switch class. RefinedAbstraction is the specific switch classes (FancySwitch, NormalSwitch etc.). Implementor is the IElectricalEquipment interface.ConcreteImplementorA and ConcreteImplementorB are the Fan and Light classes.
from:
http://www.codeproject.com/KB/architecture/LearningDesignPatterns1.aspx
]]>
]]>
1銆?span>FACTORY 鈥?/span>榪?span>MM灝戜笉浜嗚鍚冮キ浜嗭紝楹﹀綋鍔崇殑楦$繀鍜岃偗寰峰熀鐨勯浮緲呴兘鏄?span>MM鐖卞悆鐨勪笢瑗匡紝铏界劧鍙e懗鏈夋墍涓嶅悓錛屼絾涓嶇浣犲甫MM鍘婚害褰撳姵鎴栬偗寰峰熀錛屽彧綆″悜鏈嶅姟鍛樿“鏉ュ洓涓浮緲?span>”灝辮浜嗐傞害褰撳姵鍜岃偗寰峰熀灝辨槸鐢熶駭楦$繀鐨?span>Factory
宸ュ巶妯″紡錛氬鎴風被鍜屽伐鍘傜被鍒嗗紑銆傛秷璐硅呬換浣曟椂鍊欓渶瑕佹煇縐嶄駭鍝侊紝鍙渶鍚戝伐鍘傝姹傚嵆鍙傛秷璐硅呮棤欏諱慨鏀瑰氨鍙互鎺ョ撼鏂頒駭鍝併傜己鐐規槸褰撲駭鍝佷慨鏀規椂錛屽伐鍘傜被涔熻鍋氱浉搴旂殑淇敼銆傚錛氬浣曞垱寤哄強濡備綍鍚戝鎴風鎻愪緵銆?
2銆?span>BUILDER 鈥擬M鏈鐖卞惉鐨勫氨鏄?span>“鎴戠埍浣?span>”榪欏彞璇濅簡錛岃鍒頒笉鍚屽湴鏂圭殑MM,瑕佽兘澶熺敤濂逛滑鐨勬柟璦璺熷ス璇磋繖鍙ヨ瘽鍝︼紝鎴戞湁涓涓縐嶈璦緲昏瘧鏈猴紝涓婇潰姣忕璇█閮芥湁涓涓寜閿紝瑙佸埌MM鎴戝彧瑕佹寜瀵瑰簲鐨勯敭錛屽畠灝辮兘澶熺敤鐩稿簲鐨勮璦璇村嚭“鎴戠埍浣?span>”榪欏彞璇濅簡錛屽浗澶栫殑MM涔熷彲浠ヨ交鏉炬悶鎺傦紝榪欏氨鏄垜鐨?span>“鎴戠埍浣?span>”builder銆傦紙榪欎竴瀹氭瘮緹庡啗鍦ㄤ紛鎷夊厠鐢ㄧ殑緲昏瘧鏈哄ソ鍗栵級
寤洪犳ā寮?/span>錛氬皢浜у搧鐨勫唴閮ㄨ〃璞″拰浜у搧鐨勭敓鎴愯繃紼嬪垎鍓插紑鏉ワ紝浠庤屼嬌涓涓緩閫犺繃紼嬬敓鎴愬叿鏈変笉鍚岀殑鍐呴儴琛ㄨ薄鐨勪駭鍝佸璞°傚緩閫犳ā寮忎嬌寰椾駭鍝佸唴閮ㄨ〃璞″彲浠ョ嫭绔嬬殑鍙樺寲錛屽鎴蜂笉蹇呯煡閬撲駭鍝佸唴閮ㄧ粍鎴愮殑緇嗚妭銆傚緩閫犳ā寮忓彲浠ュ己鍒跺疄琛屼竴縐嶅垎姝ラ榪涜鐨勫緩閫犺繃紼嬨?
3銆?span>FACTORY METHOD 鈥?/span>璇?span>MM鍘婚害褰撳姵鍚冩眽鍫★紝涓嶅悓鐨?span>MM鏈変笉鍚岀殑鍙e懗錛岃姣忎釜閮借浣忔槸涓浠剁儲浜虹殑浜嬫儏錛屾垜涓鑸噰鐢?span>Factory Method妯″紡錛屽甫鐫MM鍒版湇鍔″憳閭e効錛岃“瑕佷竴涓眽鍫?span>”錛屽叿浣撹浠涔堟牱鐨勬眽鍫″憿錛岃MM鐩存帴璺熸湇鍔″憳璇村氨琛屼簡銆?
宸ュ巶鏂規硶妯″紡錛氭牳蹇冨伐鍘傜被涓嶅啀璐熻矗鎵鏈変駭鍝佺殑鍒涘緩錛岃屾槸灝嗗叿浣撳垱寤虹殑宸ヤ綔浜ょ粰瀛愮被鍘誨仛錛屾垚涓轟竴涓娊璞″伐鍘傝鑹詫紝浠呰礋璐g粰鍑哄叿浣撳伐鍘傜被蹇呴』瀹炵幇鐨勬帴鍙o紝鑰屼笉鎺ヨЕ鍝竴涓駭鍝佺被搴斿綋琚疄渚嬪寲榪欑緇嗚妭銆?
4銆?span>PROTOTYPE 鈥?/span>璺?span>MM鐢?span>QQ鑱婂ぉ錛屼竴瀹氳璇翠簺娣辨儏鐨勮瘽璇簡錛屾垜鎼滈泦浜嗗ソ澶氳倝楹葷殑鎯呰瘽錛岄渶瑕佹椂鍙copy鍑烘潵鏀懼埌QQ閲岄潰灝辮浜嗭紝榪欏氨鏄垜鐨勬儏璇?span>prototype浜嗐傦紙100鍧楅挶涓浠斤紝浣犺涓嶈錛?
鍘熷妯″瀷妯″紡錛氶氳繃緇欏嚭涓涓師鍨嬪璞℃潵鎸囨槑鎵瑕佸垱寤虹殑瀵硅薄鐨勭被鍨嬶紝鐒跺悗鐢ㄥ鍒惰繖涓師鍨嬪璞$殑鏂規硶鍒涘緩鍑烘洿澶氬悓綾誨瀷鐨勫璞°傚師濮嬫ā鍨嬫ā寮忓厑璁稿姩鎬佺殑澧炲姞鎴栧噺灝戜駭鍝佺被錛屼駭鍝佺被涓嶉渶瑕侀潪寰楁湁浠諱綍浜嬪厛紜畾鐨勭瓑綰х粨鏋勶紝鍘熷妯″瀷妯″紡閫傜敤浜庝換浣曠殑絳夌駭緇撴瀯銆傜己鐐規槸姣忎竴涓被閮藉繀欏婚厤澶囦竴涓厠闅嗘柟娉曘?
5銆?span>SINGLETON 鈥?/span>淇烘湁6涓紓浜殑鑰佸﹩錛屽ス浠殑鑰佸叕閮芥槸鎴戯紝鎴戝氨鏄垜浠閲岀殑鑰佸叕Sigleton錛屽ス浠彧瑕佽閬?span>“鑰佸叕”錛岄兘鏄寚鐨勫悓涓涓漢錛岄偅灝辨槸鎴?span>(鍒氭墠鍋氫簡涓ⅵ鍟︼紝鍝湁榪欎箞濂界殑浜?span>)
鍗曚緥妯″紡錛氬崟渚嬫ā寮忕‘淇濇煇涓涓被鍙湁涓涓疄渚嬶紝鑰屼笖鑷瀹炰緥鍖栧茍鍚戞暣涓郴緇熸彁渚涜繖涓疄渚嬪崟渚嬫ā寮忋傚崟渚嬫ā寮忓彧搴斿湪鏈夌湡姝g殑“鍗曚竴瀹炰緥”鐨勯渶姹傛椂鎵嶅彲浣跨敤銆?
緇撴瀯鍨嬫ā寮?
6銆?span>ADAPTER 鈥?/span>鍦ㄦ湅鍙嬭仛浼氫笂紕板埌浜嗕竴涓編濂?span>Sarah錛屼粠棣欐腐鏉ョ殑錛屽彲鎴戜笉浼氳綺よ錛屽ス涓嶄細璇存櫘閫氳瘽錛屽彧濂芥眰鍔╀簬鎴戠殑鏈嬪弸kent浜嗭紝浠栦綔涓烘垜鍜?span>Sarah涔嬮棿鐨?span>Adapter錛岃鎴戝拰Sarah鍙互鐩鎬簰浜よ皥浜?span>(涔熶笉鐭ラ亾浠栦細涓嶄細鑰嶆垜)
閫傞厤鍣ㄦā寮?/span>錛氭妸涓涓被鐨勬帴鍙e彉鎹㈡垚瀹㈡埛绔墍鏈熷緟鐨勫彟涓縐嶆帴鍙o紝浠庤屼嬌鍘熸湰鍥犳帴鍙e師鍥犱笉鍖歸厤鑰屾棤娉曚竴璧峰伐浣滅殑涓や釜綾昏兘澶熶竴璧峰伐浣溿傞傞厤綾誨彲浠ユ牴鎹弬鏁拌繑榪樹竴涓悎閫傜殑瀹炰緥緇欏鎴風銆?
7銆?span>BRIDGE 鈥?/span>鏃╀笂紕板埌MM錛岃璇存棭涓婂ソ錛屾櫄涓婄鍒?span>MM錛岃璇存櫄涓婂ソ錛涚鍒?span>MM絀夸簡浠舵柊琛f湇錛岃璇翠綘鐨勮。鏈嶅ソ婕備寒鍝︼紝紕板埌MM鏂板仛鐨勫彂鍨嬶紝瑕佽浣犵殑澶村彂濂芥紓浜摝銆備笉瑕侀棶鎴?span>“鏃╀笂紕板埌MM鏂板仛浜嗕釜鍙戝瀷鎬庝箞璇?span>”榪欑闂錛岃嚜宸辯敤BRIDGE緇勫悎涓涓嬩笉灝辮浜?
妗ユ妯″紡錛氬皢鎶借薄鍖栦笌瀹炵幇鍖栬劚鑰︼紝浣垮緱浜岃呭彲浠ョ嫭绔嬬殑鍙樺寲錛屼篃灝辨槸璇村皢浠栦滑涔嬮棿鐨勫己鍏寵仈鍙樻垚寮卞叧鑱旓紝涔熷氨鏄寚鍦ㄤ竴涓蔣浠剁郴緇熺殑鎶借薄鍖栧拰瀹炵幇鍖栦箣闂翠嬌鐢ㄧ粍鍚?span>/鑱氬悎鍏崇郴鑰屼笉鏄戶鎵垮叧緋伙紝浠庤屼嬌涓よ呭彲浠ョ嫭绔嬬殑鍙樺寲銆?
8銆?span>COMPOSITE 鈥擬ary浠婂ぉ榪囩敓鏃ャ?span>“鎴戣繃鐢熸棩錛屼綘瑕侀佹垜涓浠剁ぜ鐗┿?span>”“鍡紝濂藉惂錛屽幓鍟嗗簵錛屼綘鑷繁鎸戙?span>”“榪欎歡T鎭ゆ尯婕備寒錛屼拱錛岃繖鏉¤瀛愬ソ鐪嬶紝涔幫紝榪欎釜鍖呬篃涓嶉敊錛屼拱銆?span>”“鍠傦紝涔頒簡涓変歡浜嗗憖錛屾垜鍙瓟搴旈佷竴浠剁ぜ鐗╃殑鍝︺?span>”“浠涔堝憖錛?span>T鎭ゅ姞瑁欏瓙鍔犲寘鍖咃紝姝eソ閰嶆垚涓濂楀憖錛屽皬濮愶紝楹葷儲浣犲寘璧鋒潵銆?span>”“……”錛?span>MM閮戒細鐢?span>Composite妯″紡浜嗭紝浣犱細浜嗘病鏈夛紵
鍚堟垚妯″紡錛氬悎鎴愭ā寮忓皢瀵硅薄緇勭粐鍒版爲緇撴瀯涓紝鍙互鐢ㄦ潵鎻忚堪鏁翠綋涓庨儴鍒嗙殑鍏崇郴銆傚悎鎴愭ā寮忓氨鏄竴涓鐞嗗璞$殑鏍戠粨鏋勭殑妯″紡銆傚悎鎴愭ā寮忔妸閮ㄥ垎涓庢暣浣撶殑鍏崇郴鐢ㄦ爲緇撴瀯琛ㄧず鍑烘潵銆傚悎鎴愭ā寮忎嬌寰楀鎴風鎶婁竴涓釜鍗曠嫭鐨勬垚鍒嗗璞″拰鐢變粬浠鍚堣屾垚鐨勫悎鎴愬璞″悓絳夌湅寰呫?
9銆?span>DECORATOR 鈥擬ary榪囧畬杞埌Sarly榪囩敓鏃ワ紝榪樻槸涓嶈鍙ス鑷繁鎸戜簡錛屼笉鐒惰繖涓湀浼欓璐硅偗瀹氱帺瀹岋紝鎷垮嚭鎴戝幓騫村湪鍗庡北欏朵笂鐓х殑鐓х墖錛屽湪鑳岄潰鍐欎笂“鏈濂界殑鐨勭ぜ鐗╋紝灝辨槸鐖變綘鐨?span>Fita”錛屽啀鍒拌涓婄ぜ鍝佸簵涔頒簡涓儚妗嗭紙鍗栫ぜ鍝佺殑MM涔熷緢婕備寒鍝︼級錛屽啀鎵鵑殧澹佹悶緹庢湳璁捐鐨?span>Mike璁捐浜嗕竴涓紓浜殑鐩掑瓙瑁呰搗鏉?span>……錛屾垜浠兘鏄?span>Decorator錛屾渶緇堥兘鍦ㄤ慨楗版垜榪欎釜浜哄憖錛屾庝箞鏍鳳紝鐪嬫噦浜嗗悧錛?
瑁呴グ妯″紡錛氳楗版ā寮忎互瀵瑰鎴風閫忔槑鐨勬柟寮忔墿灞曞璞$殑鍔熻兘錛屾槸緇ф壙鍏崇郴鐨勪竴涓浛浠f柟妗堬紝鎻愪緵姣旂戶鎵挎洿澶氱殑鐏墊椿鎬с傚姩鎬佺粰涓涓璞″鍔犲姛鑳斤紝榪欎簺鍔熻兘鍙互鍐嶅姩鎬佺殑鎾ゆ秷銆傚鍔犵敱涓浜涘熀鏈姛鑳界殑鎺掑垪緇勫悎鑰屼駭鐢熺殑闈炲父澶ч噺鐨勫姛鑳姐?
10銆?span>FAÇADE 鈥?/span>鎴戞湁涓涓笓涓氱殑Nikon鐩告満錛屾垜灝卞枩嬈㈣嚜宸辨墜鍔ㄨ皟鍏夊湀銆佸揩闂紝榪欐牱鐓у嚭鏉ョ殑鐓х墖鎵嶄笓涓氾紝浣?span>MM鍙笉鎳傝繖浜涳紝鏁欎簡鍗婂ぉ涔熶笉浼氥傚垢濂界浉鏈烘湁Facade璁捐妯″紡錛屾妸鐩告満璋冩暣鍒拌嚜鍔ㄦ。錛屽彧瑕佸鍑嗙洰鏍囨寜蹇棬灝辮浜嗭紝涓鍒囩敱鐩告満鑷姩璋冩暣錛岃繖鏍?span>MM涔熷彲浠ョ敤榪欎釜鐩告満緇欐垜鎷嶅紶鐓х墖浜嗐?
闂ㄩ潰妯″紡錛氬閮ㄤ笌涓涓瓙緋葷粺鐨勯氫俊蹇呴』閫氳繃涓涓粺涓鐨勯棬闈㈠璞¤繘琛屻傞棬闈㈡ā寮忔彁渚涗竴涓珮灞傛鐨勬帴鍙o紝浣垮緱瀛愮郴緇熸洿鏄撲簬浣跨敤銆傛瘡涓涓瓙緋葷粺鍙湁涓涓棬闈㈢被錛岃屼笖姝ら棬闈㈢被鍙湁涓涓疄渚嬶紝涔熷氨鏄瀹冩槸涓涓崟渚嬫ā寮忋備絾鏁翠釜緋葷粺鍙互鏈夊涓棬闈㈢被銆?
11銆?span>FLYWEIGHT 鈥?/span>姣忓ぉ璺?span>MM鍙戠煭淇★紝鎵嬫寚閮界瘡姝諱簡錛屾渶榪戜拱浜嗕釜鏂版墜鏈猴紝鍙互鎶婁竴浜涘父鐢ㄧ殑鍙ュ瓙瀛樺湪鎵嬫満閲岋紝瑕佺敤鐨勬椂鍊欙紝鐩存帴鎷垮嚭鏉ワ紝鍦ㄥ墠闈㈠姞涓?span>MM鐨勫悕瀛楀氨鍙互鍙戦佷簡錛屽啀涓嶇敤涓涓瓧涓涓瓧鏁蹭簡銆傚叡浜殑鍙ュ瓙灝辨槸Flyweight錛?span>MM鐨勫悕瀛楀氨鏄彁鍙栧嚭鏉ョ殑澶栭儴鐗瑰緛錛屾牴鎹笂涓嬫枃鎯呭喌浣跨敤銆?
浜厓妯″紡錛?span>FLYWEIGHT鍦ㄦ嫵鍑繪瘮璧涗腑鎸囨渶杞婚噺綰с備韓鍏冩ā寮忎互鍏變韓鐨勬柟寮忛珮鏁堢殑鏀寔澶ч噺鐨勭粏綺掑害瀵硅薄銆備韓鍏冩ā寮忚兘鍋氬埌鍏變韓鐨勫叧閿槸鍖哄垎鍐呰暣鐘舵佸拰澶栬暣鐘舵併傚唴钑寸姸鎬佸瓨鍌ㄥ湪浜厓鍐呴儴錛屼笉浼氶殢鐜鐨勬敼鍙樿屾湁鎵涓嶅悓銆傚钑寸姸鎬佹槸闅忕幆澧冪殑鏀瑰彉鑰屾敼鍙樼殑銆傚钑寸姸鎬佷笉鑳藉獎鍝嶅唴钑寸姸鎬侊紝瀹冧滑鏄浉浜掔嫭绔嬬殑銆傚皢鍙互鍏變韓鐨勭姸鎬佸拰涓嶅彲浠ュ叡浜殑鐘舵佷粠甯歌綾諱腑鍖哄垎寮鏉ワ紝灝嗕笉鍙互鍏變韓鐨勭姸鎬佷粠綾婚噷鍓旈櫎鍑哄幓銆傚鎴風涓嶅彲浠ョ洿鎺ュ垱寤鴻鍏變韓鐨勫璞★紝鑰屽簲褰撲嬌鐢ㄤ竴涓伐鍘傚璞¤礋璐e垱寤鴻鍏變韓鐨勫璞°備韓鍏冩ā寮忓ぇ騫呭害鐨勯檷浣庡唴瀛樹腑瀵硅薄鐨勬暟閲忋?
12銆?span>PROXY 鈥?/span>璺?span>MM鍦ㄧ綉涓婅亰澶╋紝涓寮澶存繪槸“hi,浣犲ソ”,“浣犱粠鍝効鏉ュ憖錛?span>”“浣犲澶т簡錛?span>”“韜珮澶氬皯鍛錛?span>”榪欎簺璇濓紝鐪熺儲浜猴紝鍐欎釜紼嬪簭鍋氫負鎴戠殑Proxy鍚э紝鍑℃槸鎺ユ敹鍒拌繖浜涜瘽閮借緗ソ浜嗚嚜鍔ㄧ殑鍥炵瓟錛屾帴鏀跺埌鍏朵粬鐨勮瘽鏃跺啀閫氱煡鎴戝洖絳旓紝鎬庝箞鏍鳳紝閰峰惂銆?
浠g悊妯″紡錛氫唬鐞嗘ā寮忕粰鏌愪竴涓璞℃彁渚涗竴涓唬鐞嗗璞★紝騫剁敱浠g悊瀵硅薄鎺у埗瀵規簮瀵硅薄鐨勫紩鐢ㄣ備唬鐞嗗氨鏄竴涓漢鎴栦竴涓満鏋勪唬琛ㄥ彟涓涓漢鎴栬呬竴涓満鏋勯噰鍙栬鍔ㄣ傛煇浜涙儏鍐典笅錛屽鎴蜂笉鎯蟲垨鑰呬笉鑳藉鐩存帴寮曠敤涓涓璞★紝浠g悊瀵硅薄鍙互鍦ㄥ鎴峰拰鐩爣瀵硅薄鐩存帴璧峰埌涓粙鐨勪綔鐢ㄣ傚鎴風鍒嗚鯨涓嶅嚭浠g悊涓婚瀵硅薄涓庣湡瀹炰富棰樺璞°備唬鐞嗘ā寮忓彲浠ュ茍涓嶇煡閬撶湡姝g殑琚唬鐞嗗璞★紝鑰屼粎浠呮寔鏈変竴涓浠g悊瀵硅薄鐨勬帴鍙o紝榪欐椂鍊欎唬鐞嗗璞′笉鑳藉鍒涘緩琚唬鐞嗗璞★紝琚唬鐞嗗璞″繀欏繪湁緋葷粺鐨勫叾浠栬鑹蹭唬涓哄垱寤哄茍浼犲叆銆?
琛屼負妯″紡
13銆?span>CHAIN OF RESPONSIBLEITY 鈥?/span>鏅氫笂鍘諱笂鑻辮璇撅紝涓轟簡濂藉紑婧滃潗鍒頒簡鏈鍚庝竴鎺掞紝鍝囷紝鍓嶉潰鍧愪簡濂藉嚑涓紓浜殑MM鍝庯紝鎵懼紶綰告潯錛屽啓涓?span>“Hi,鍙互鍋氭垜鐨勫コ鏈嬪弸鍚楋紵濡傛灉涓嶆効鎰忚鍚戝墠浼?span>”錛岀焊鏉″氨涓涓帴涓涓殑浼犱笂鍘諱簡錛岀碂緋曪紝浼犲埌絎竴鎺掔殑MM鎶婄焊鏉′紶緇欒佸笀浜嗭紝鍚鏄釜鑰佸濂沖憖錛屽揩璺?span>!
璐d換閾炬ā寮?/span>錛氬湪璐d換閾炬ā寮忎腑錛屽緢澶氬璞$敱姣忎竴涓璞″鍏朵笅瀹剁殑寮曠敤鑰屾帴璧鋒潵褰㈡垚涓鏉¢摼銆傝姹傚湪榪欎釜閾句笂浼犻掞紝鐩村埌閾句笂鐨勬煇涓涓璞″喅瀹氬鐞嗘璇鋒眰銆傚鎴峰茍涓嶇煡閬撻摼涓婄殑鍝竴涓璞℃渶緇堝鐞嗚繖涓姹傦紝緋葷粺鍙互鍦ㄤ笉褰卞搷瀹㈡埛绔殑鎯呭喌涓嬪姩鎬佺殑閲嶆柊緇勭粐閾懼拰鍒嗛厤璐d換銆傚鐞嗚呮湁涓や釜閫夋嫨錛氭壙鎷呰矗浠繪垨鑰呮妸璐d換鎺ㄧ粰涓嬪銆備竴涓姹傚彲浠ユ渶緇堜笉琚換浣曟帴鏀剁瀵硅薄鎵鎺ュ彈銆?
14銆?span>COMMAND 鈥?/span>淇烘湁涓涓?span>MM瀹墮噷綆″緱鐗瑰埆涓ワ紝娌℃硶瑙侀潰錛屽彧濂藉熷姪浜庡ス寮熷紵鍦ㄦ垜浠咯涔嬮棿浼犻佷俊鎭紝濂瑰鎴戞湁浠涔堟寚紺猴紝灝卞啓涓寮犵焊鏉¤濂瑰紵寮熷甫緇欐垜銆傝繖涓嶏紝濂瑰紵寮熷張浼犻佽繃鏉ヤ竴涓?span>COMMAND錛屼負浜嗘劅璋粬錛屾垜璇蜂粬鍚冧簡紕楁潅閰遍潰錛屽摢鐭ラ亾浠栬錛?span>“鎴戝悓鏃剁粰鎴戝濮愪笁涓敺鏈嬪弸閫?span>COMMAND錛屽氨鏁頒綘鏈灝忔皵錛屾墠璇鋒垜鍚冮潰銆?span>”錛?/span>
鍛戒護妯″紡錛氬懡浠ゆā寮忔妸涓涓姹傛垨鑰呮搷浣滃皝瑁呭埌涓涓璞′腑銆傚懡浠ゆā寮忔妸鍙戝嚭鍛戒護鐨勮矗浠誨拰鎵ц鍛戒護鐨勮矗浠誨垎鍓插紑錛屽媧劇粰涓嶅悓鐨勫璞°傚懡浠ゆā寮忓厑璁歌姹傜殑涓鏂瑰拰鍙戦佺殑涓鏂圭嫭绔嬪紑鏉ワ紝浣垮緱璇鋒眰鐨勪竴鏂逛笉蹇呯煡閬撴帴鏀惰姹傜殑涓鏂圭殑鎺ュ彛錛屾洿涓嶅繀鐭ラ亾璇鋒眰鏄庝箞琚帴鏀訛紝浠ュ強鎿嶄綔鏄惁鎵ц錛屼綍鏃惰鎵ц浠ュ強鏄庝箞琚墽琛岀殑銆傜郴緇熸敮鎸佸懡浠ょ殑鎾ゆ秷銆?
15銆?span>INTERPRETER 鈥?/span>淇烘湁涓涓婃場MM鐪熺粡銆嬶紝涓婇潰鏈夊悇縐嶆場MM鐨勬敾鐣ワ紝姣斿璇村幓鍚冭タ槨愮殑姝ラ銆佸幓鐪嬬數褰辯殑鏂規硶絳夌瓑錛岃窡MM綰︿細鏃訛紝鍙鍋氫竴涓?span>Interpreter錛岀収鐫涓婇潰鐨勮剼鏈墽琛屽氨鍙互浜嗐?
瑙i噴鍣ㄦā寮?/span>錛氱粰瀹氫竴涓璦鍚庯紝瑙i噴鍣ㄦā寮忓彲浠ュ畾涔夊嚭鍏舵枃娉曠殑涓縐嶈〃紺猴紝騫跺悓鏃舵彁渚涗竴涓В閲婂櫒銆傚鎴風鍙互浣跨敤榪欎釜瑙i噴鍣ㄦ潵瑙i噴榪欎釜璇█涓殑鍙ュ瓙銆傝В閲婂櫒妯″紡灝嗘弿榪版庢牱鍦ㄦ湁浜嗕竴涓畝鍗曠殑鏂囨硶鍚庯紝浣跨敤妯″紡璁捐瑙i噴榪欎簺璇彞銆傚湪瑙i噴鍣ㄦā寮忛噷闈㈡彁鍒扮殑璇█鏄寚浠諱綍瑙i噴鍣ㄥ璞¤兘澶熻В閲婄殑浠諱綍緇勫悎銆傚湪瑙i噴鍣ㄦā寮忎腑闇瑕佸畾涔変竴涓唬琛ㄦ枃娉曠殑鍛戒護綾葷殑絳夌駭緇撴瀯錛屼篃灝辨槸涓緋誨垪鐨勭粍鍚堣鍒欍傛瘡涓涓懡浠ゅ璞¢兘鏈変竴涓В閲婃柟娉曪紝浠h〃瀵瑰懡浠ゅ璞$殑瑙i噴銆傚懡浠ゅ璞$殑絳夌駭緇撴瀯涓殑瀵硅薄鐨勪換浣曟帓鍒楃粍鍚堥兘鏄竴涓璦銆?
16銆?span>ITERATOR 鈥?/span>鎴戠埍涓婁簡Mary錛屼笉欏句竴鍒囩殑鍚戝ス姹傚銆?
Mary錛?span>“鎯寵鎴戣窡浣犵粨濠氾紝寰楃瓟搴旀垜鐨勬潯浠?span>”
鎴戯細“浠涔堟潯浠舵垜閮界瓟搴旓紝浣犺鍚?span>”
Mary錛?span>“鎴戠湅涓婁簡閭d釜涓鍏嬫媺鐨勯捇鐭?span>”
鎴戯細“鎴戜拱錛屾垜涔幫紝榪樻湁鍚楋紵”
Mary錛?span>“鎴戠湅涓婁簡婀栬竟鐨勯偅鏍嬪埆澧?span>”
鎴戯細“鎴戜拱錛屾垜涔幫紝榪樻湁鍚楋紵”
Mary錛?span>“浣犵殑灝忓紵寮熷繀欏昏鏈?chmetcnv unitname="cm" sourcevalue="50" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">50cm闀?span>”
鎴戣剳琚嬪棥鐨勪竴澹幫紝鍧愬湪妞呭瓙涓婏紝涓鍜墮錛?span>“鎴戝壀錛屾垜鍓紝榪樻湁鍚楋紵”
……
榪唬瀛愭ā寮?/span>錛氳凱浠e瓙妯″紡鍙互欏哄簭璁塊棶涓涓仛闆嗕腑鐨勫厓绱犺屼笉蹇呮毚闇茶仛闆嗙殑鍐呴儴琛ㄨ薄銆傚涓璞¤仛鍦ㄤ竴璧峰艦鎴愮殑鎬諱綋縐頒箣涓鴻仛闆嗭紝鑱氶泦瀵硅薄鏄兘澶熷寘瀹逛竴緇勫璞$殑瀹瑰櫒瀵硅薄銆傝凱浠e瓙妯″紡灝嗚凱浠i昏緫灝佽鍒頒竴涓嫭绔嬬殑瀛愬璞′腑錛屼粠鑰屼笌鑱氶泦鏈韓闅斿紑銆傝凱浠e瓙妯″紡綆鍖栦簡鑱氶泦鐨勭晫闈€傛瘡涓涓仛闆嗗璞¢兘鍙互鏈変竴涓垨涓涓互涓婄殑榪唬瀛愬璞★紝姣忎竴涓凱浠e瓙鐨勮凱浠g姸鎬佸彲浠ユ槸褰兼鐙珛鐨勩傝凱浠g畻娉曞彲浠ョ嫭绔嬩簬鑱氶泦瑙掕壊鍙樺寲銆?
17銆?span>MEDIATOR 鈥?/span>鍥涗釜MM鎵撻夯灝嗭紝鐩鎬簰涔嬮棿璋佸簲璇ョ粰璋佸灝戦挶綆椾笉娓呮浜嗭紝騫鎬簭褰撴椂鎴戝湪鏃佽竟錛屾寜鐓у悇鑷殑絳圭爜鏁扮畻閽憋紝璧氫簡閽辯殑浠庢垜榪欓噷鎷匡紝璧斾簡閽辯殑涔熶粯緇欐垜錛屼竴鍒囧氨OK鍟︼紝淇哄緱鍒頒簡鍥涗釜MM鐨勭數璇濄?
璋冨仠鑰呮ā寮?/span>錛氳皟鍋滆呮ā寮忓寘瑁呬簡涓緋誨垪瀵硅薄鐩鎬簰浣滅敤鐨勬柟寮忥紝浣垮緱榪欎簺瀵硅薄涓嶅繀鐩鎬簰鏄庢樉浣滅敤銆備粠鑰屼嬌浠栦滑鍙互鏉炬暎鍋跺悎銆傚綋鏌愪簺瀵硅薄涔嬮棿鐨勪綔鐢ㄥ彂鐢熸敼鍙樻椂錛屼笉浼氱珛鍗沖獎鍝嶅叾浠栫殑涓浜涘璞′箣闂寸殑浣滅敤銆備繚璇佽繖浜涗綔鐢ㄥ彲浠ュ郊姝ょ嫭绔嬬殑鍙樺寲銆傝皟鍋滆呮ā寮忓皢澶氬澶氱殑鐩鎬簰浣滅敤杞寲涓轟竴瀵瑰鐨勭浉浜掍綔鐢ㄣ傝皟鍋滆呮ā寮忓皢瀵硅薄鐨勮涓哄拰鍗忎綔鎶借薄鍖栵紝鎶婂璞″湪灝忓昂搴︾殑琛屼負涓婁笌鍏朵粬瀵硅薄鐨勭浉浜掍綔鐢ㄥ垎寮澶勭悊銆?
18銆?span>MEMENTO 鈥?/span>鍚屾椂璺熷嚑涓?span>MM鑱婂ぉ鏃訛紝涓瀹氳璁版竻妤氬垰鎵嶈窡MM璇翠簡浜涗粈涔堣瘽錛屼笉鐒?span>MM鍙戠幇浜嗕細涓嶉珮鍏寸殑鍝︼紝騫鎬簭鎴戞湁涓蹇樺綍錛屽垰鎵嶄笌鍝釜MM璇翠簡浠涔堣瘽鎴戦兘鎷瘋礉涓浠芥斁鍒板蹇樺綍閲岄潰淇濆瓨錛岃繖鏍峰彲浠ラ殢鏃跺療鐪嬩互鍓嶇殑璁板綍鍟︺?
澶囧繕褰曟ā寮?/span>錛氬蹇樺綍瀵硅薄鏄竴涓敤鏉ュ瓨鍌ㄥ彟澶栦竴涓璞″唴閮ㄧ姸鎬佺殑蹇収鐨勫璞°傚蹇樺綍妯″紡鐨勭敤鎰忔槸鍦ㄤ笉鐮村潖灝佽鐨勬潯浠朵笅錛屽皢涓涓璞$殑鐘舵佹崏浣忥紝騫跺閮ㄥ寲錛屽瓨鍌ㄨ搗鏉ワ紝浠庤屽彲浠ュ湪灝嗘潵鍚堥傜殑鏃跺欐妸榪欎釜瀵硅薄榪樺師鍒板瓨鍌ㄨ搗鏉ョ殑鐘舵併?
19銆?span>OBSERVER 鈥?/span>鎯崇煡閬撳挶浠叕鍙告渶鏂?span>MM鎯呮姤鍚楋紵鍔犲叆鍏徃鐨?span>MM鎯呮姤閭歡緇勫氨琛屼簡錛?span>tom璐熻矗鎼滈泦鎯呮姤錛屼粬鍙戠幇鐨勬柊鎯呮姤涓嶇敤涓涓竴涓氱煡鎴戜滑錛岀洿鎺ュ彂甯冪粰閭歡緇勶紝鎴戜滑浣滀負璁㈤槄鑰咃紙瑙傚療鑰咃級灝卞彲浠ュ強鏃舵敹鍒版儏鎶ュ暒
瑙傚療鑰呮ā寮?/span>錛氳瀵熻呮ā寮忓畾涔変簡涓縐嶄竴闃熷鐨勪緷璧栧叧緋伙紝璁╁涓瀵熻呭璞″悓鏃剁洃鍚煇涓涓富棰樺璞°傝繖涓富棰樺璞″湪鐘舵佷笂鍙戠敓鍙樺寲鏃訛紝浼氶氱煡鎵鏈夎瀵熻呭璞★紝浣夸粬浠兘澶熻嚜鍔ㄦ洿鏂拌嚜宸便?
20銆?span>STATE 鈥?/span>璺?span>MM浜ゅ線鏃訛紝涓瀹氳娉ㄦ剰濂圭殑鐘舵佸摝錛屽湪涓嶅悓鐨勭姸鎬佹椂濂圭殑琛屼負浼氭湁涓嶅悓錛屾瘮濡備綘綰﹀ス浠婂ぉ鏅氫笂鍘葷湅鐢靛獎錛屽浣犳病鍏磋叮鐨?span>MM灝變細璇?span>“鏈変簨鎯呭暒”錛屽浣犱笉璁ㄥ帉浣嗚繕娌″枩嬈笂鐨?span>MM灝變細璇?span>“濂藉晩錛屼笉榪囧彲浠ュ甫涓婃垜鍚屼簨涔堬紵”錛屽凡緇忓枩嬈笂浣犵殑MM灝變細璇?span>“鍑犵偣閽燂紵鐪嬪畬鐢靛獎鍐嶅幓娉″惂鎬庝箞鏍鳳紵”錛屽綋鐒朵綘鐪嬬數褰辮繃紼嬩腑琛ㄧ幇鑹ソ鐨勮瘽錛屼篃鍙互鎶?span>MM鐨勭姸鎬佷粠涓嶈鍘屼笉鍠滄鍙樻垚鍠滄鍝︺?
鐘舵佹ā寮?/span>錛氱姸鎬佹ā寮忓厑璁鎬竴涓璞″湪鍏跺唴閮ㄧ姸鎬佹敼鍙樼殑鏃跺欐敼鍙樿涓恒傝繖涓璞$湅涓婂幓璞℃槸鏀瑰彉浜嗗畠鐨勭被涓鏍楓傜姸鎬佹ā寮忔妸鎵鐮旂┒鐨勫璞$殑琛屼負鍖呰鍦ㄤ笉鍚岀殑鐘舵佸璞¢噷錛屾瘡涓涓姸鎬佸璞¢兘灞炰簬涓涓娊璞$姸鎬佺被鐨勪竴涓瓙綾匯傜姸鎬佹ā寮忕殑鎰忓浘鏄涓涓璞″湪鍏跺唴閮ㄧ姸鎬佹敼鍙樼殑鏃跺欙紝鍏惰涓轟篃闅忎箣鏀瑰彉銆傜姸鎬佹ā寮忛渶瑕佸姣忎竴涓郴緇熷彲鑳藉彇寰楃殑鐘舵佸垱绔嬩竴涓姸鎬佺被鐨勫瓙綾匯傚綋緋葷粺鐨勭姸鎬佸彉鍖栨椂錛岀郴緇熶究鏀瑰彉鎵閫夌殑瀛愮被銆?
21銆?span>STRATEGY 鈥?/span>璺熶笉鍚岀被鍨嬬殑MM綰︿細錛岃鐢ㄤ笉鍚岀殑絳栫暐錛屾湁鐨勮鐢靛獎姣旇緝濂斤紝鏈夌殑鍒欏幓鍚冨皬鍚冩晥鏋滀笉閿欙紝鏈夌殑鍘繪搗杈規氮婕渶鍚堥傦紝鍗曠洰鐨勯兘鏄負浜嗗緱鍒?span>MM鐨勮姵蹇冿紝鎴戠殑榪?span>MM閿﹀泭涓湁濂藉Strategy鍝︺?
絳栫暐妯″紡錛氱瓥鐣ユā寮忛拡瀵逛竴緇勭畻娉曪紝灝嗘瘡涓涓畻娉曞皝瑁呭埌鍏鋒湁鍏卞悓鎺ュ彛鐨勭嫭绔嬬殑綾諱腑錛屼粠鑰屼嬌寰楀畠浠彲浠ョ浉浜掓浛鎹€傜瓥鐣ユā寮忎嬌寰楃畻娉曞彲浠ュ湪涓嶅獎鍝嶅埌瀹㈡埛绔殑鎯呭喌涓嬪彂鐢熷彉鍖栥傜瓥鐣ユā寮忔妸琛屼負鍜岀幆澧冨垎寮銆傜幆澧冪被璐熻矗緇存寔鍜屾煡璇㈣涓虹被錛屽悇縐嶇畻娉曞湪鍏蜂綋鐨勭瓥鐣ョ被涓彁渚涖傜敱浜庣畻娉曞拰鐜鐙珛寮鏉ワ紝綆楁硶鐨勫鍑忥紝淇敼閮戒笉浼氬獎鍝嶅埌鐜鍜屽鎴風銆?
22銆?span>TEMPLATE METHOD 鈥斺?/span>鐪嬭繃銆婂浣曡鏈嶅コ鐢熶笂搴娿嬭繖閮ㄧ粡鍏告枃绔犲悧錛熷コ鐢熶粠璁よ瘑鍒頒笂搴婄殑涓嶅彉鐨勬楠ゅ垎涓哄閥閬囥佹墦鐮村兊灞銆佸睍寮榪芥眰銆佹帴鍚匯佸墠鎴忋佸姩鎵嬨佺埍鎶氥佽繘鍘誨叓澶ф楠?span>(Template method)錛屼絾姣忎釜姝ラ閽堝涓嶅悓鐨勬儏鍐碉紝閮芥湁涓嶄竴鏍風殑鍋氭硶錛岃繖灝辮鐪嬩綘闅忔満搴斿彉鍟?span>(鍏蜂綋瀹炵幇)錛?
妯℃澘鏂規硶妯″紡錛氭ā鏉挎柟娉曟ā寮忓噯澶囦竴涓娊璞$被錛屽皢閮ㄥ垎閫昏緫浠ュ叿浣撴柟娉曚互鍙婂叿浣撴瀯閫犲瓙鐨勫艦寮忓疄鐜幫紝鐒跺悗澹版槑涓浜涙娊璞℃柟娉曟潵榪嬌瀛愮被瀹炵幇鍓╀綑鐨勯昏緫銆備笉鍚岀殑瀛愮被鍙互浠ヤ笉鍚岀殑鏂瑰紡瀹炵幇榪欎簺鎶借薄鏂規硶錛屼粠鑰屽鍓╀綑鐨勯昏緫鏈変笉鍚岀殑瀹炵幇銆傚厛鍒跺畾涓涓《綰ч昏緫妗嗘灦錛岃屽皢閫昏緫鐨勭粏鑺傜暀緇欏叿浣撶殑瀛愮被鍘誨疄鐜般?
23銆?span>VISITOR 鈥?/span>鎯呬漢鑺傚埌浜嗭紝瑕佺粰姣忎釜MM閫佷竴鏉熼矞鑺卞拰涓寮犲崱鐗囷紝鍙槸姣忎釜MM閫佺殑鑺遍兘瑕侀拡瀵瑰ス涓漢鐨勭壒鐐癸紝姣忓紶鍗$墖涔熻鏍規嵁涓漢鐨勭壒鐐規潵鎸戯紝鎴戜竴涓漢鍝悶寰楁竻妤氾紝榪樻槸鎵捐姳搴楄佹澘鍜岀ぜ鍝佸簵鑰佹澘鍋氫竴涓?span>Visitor錛岃鑺卞簵鑰佹澘鏍規嵁MM鐨勭壒鐐歸変竴鏉熻姳錛岃紺煎搧搴楄佹澘涔熸牴鎹瘡涓漢鐗圭偣閫変竴寮犲崱錛岃繖鏍峰氨杞繪澗澶氫簡錛?
璁塊棶鑰呮ā寮?/span>錛氳闂呮ā寮忕殑鐩殑鏄皝瑁呬竴浜涙柦鍔犱簬鏌愮鏁版嵁緇撴瀯鍏冪礌涔嬩笂鐨勬搷浣溿備竴鏃﹁繖浜涙搷浣滈渶瑕佷慨鏀圭殑璇濓紝鎺ュ彈榪欎釜鎿嶄綔鐨勬暟鎹粨鏋勫彲浠ヤ繚鎸佷笉鍙樸傝闂呮ā寮忛傜敤浜庢暟鎹粨鏋勭浉瀵規湭瀹氱殑緋葷粺錛屽畠鎶婃暟鎹粨鏋勫拰浣滅敤浜庣粨鏋勪笂鐨勬搷浣滀箣闂寸殑鑰﹀悎瑙h劚寮錛屼嬌寰楁搷浣滈泦鍚堝彲浠ョ浉瀵硅嚜鐢辯殑婕斿寲銆傝闂呮ā寮忎嬌寰楀鍔犳柊鐨勬搷浣滃彉鐨勫緢瀹規槗錛屽氨鏄鍔犱竴涓柊鐨勮闂呯被銆傝闂呮ā寮忓皢鏈夊叧鐨勮涓洪泦涓埌涓涓闂呭璞′腑錛岃屼笉鏄垎鏁e埌涓涓釜鐨勮妭鐐圭被涓傚綋浣跨敤璁塊棶鑰呮ā寮忔椂錛岃灝嗗敖鍙兘澶氱殑瀵硅薄嫻忚閫昏緫鏀懼湪璁塊棶鑰呯被涓紝鑰屼笉鏄斁鍒板畠鐨勫瓙綾諱腑銆傝闂呮ā寮忓彲浠ヨ法榪囧嚑涓被鐨勭瓑綰х粨鏋勮闂睘浜庝笉鍚岀殑絳夌駭緇撴瀯鐨勬垚鍛樼被銆?/span>
]]>