Design pattern of OOP in Flash

Source: Internet
Author: User
Tags abstract constructor copy generator include variables relative xml parser
Design

Someone asked me how flash as should be written, I can tell him responsibly how to write, because as and the composition of flash internal mode determines its high degree of liberalization. Theoretically, using the button on event, plus stop (), play (), gotoAndStop (), gotoAndPlay (), can achieve most of the logical relationship in a flash, and the source code is easy to understand. But most people don't do it because it's a very admirable way to do it. A programmer with a bit of common sense will know the difference between facing an object and facing a process. Flash programming, although only in the form of a script, and still very imperfect, for example, not many inheritance, but has initially embodied the idea of OOP. This article now summarizes flash in the face of the design pattern of objects, as well as some of the creative thinking.

Design mode is a master of architecture in the United States (also information engineers, painters, Mechanical Engineers ...). Christian Alexander first proposed, soon by the software industry technicians accepted the promotion, become one of the supreme laws of engineering (interested people can find his "architecture of the Eternal Road," a book to see, I believe that will benefit not shallow). Simply put, in the face of the object, including the face of the object, the overall design of the various parts of the pattern, hierarchical, fine-grained, highly reusable, controllable, user-friendly. The paramount principle is based on demand, that is to say, no matter what, people's needs should be considered first, from this point of view the whole system is reasonable enough. This learning is very interesting, especially in Flash, can be applied to a lot of interesting examples. Below I follow some general design patterns, examples, there are errors in the place, please master correct:

1. Abstract Factory mode (abstracts Factory)
The canteen to eat a lot of things, and I just want to eat the same, then canteen this concept for me is an abstract factory, each window can be seen as a concrete realization of it, I have to do is, to the canteen, to find that window, from the window to buy what I want to eat.

Example: Flash foreground and ASP background interaction, access to a dynamic page, from the database to remove the required data, the usual practice is in the background of the dataset to parse into an XML string, and then to the SWF. Each business logic module, the data structure taken out, that is, the structure of the XML is not the same, we need to target the specific business logic, the corresponding XML string parsing, into the array to display. Also want to convert the contents of the text input in Flash into an XML string, submitted to the background also face

Abstractfactory.as
Interfaces for abstract factories
Interface abstractfactory{
The concrete implementation of generating XML parsing factory
function Createxmlparsefactory ();
}

Xmlparsergetfactory.as
The factory that generates the objects that parse the read XML
Class Xmlparsergetfactory implements Abstractfactory. {
var Xmlparser;
function Xmlparsergetfactory (str:string) {
The concrete implementation of the parser is generated, which is mentioned later
}
function Createxmlparser () {
return xmlparser;
}
}
Xmlparserpostfactory.as
A factory that generates objects for XML that resolves output
Class Xmlparserpostfactory implements Abstractfactory. {
var Xmlparser;
function Xmlparserpostfactory (str:string) {
The concrete implementation of the generation parser
}
function Createxmlparser () {
return xmlparser;
}
}

So, when we read an XML string, we add it in the onload
Create a factory that resolves a message list on a message board
var xmlparser=new xmlparsergetfactory ("Xmlparseguestbooklist")
Xmlparser= xmlparsergetfactory. Createxmlparser ()

Note: Abstract Factory mode is one of the most common design patterns in software engineering. The implementation process is that when an instance of a class is needed, it is created through a factory rather than created directly, and frankly, it increases the amount of development effort, but it helps to make the hierarchy of the program clear and reduce coupling.

2. Generator mode (builder)
or that said, I want to eat to go to the corresponding canteen window, but I can not canteen the window, the window of the things may be a lot, I want to tell the master, to this, this, and this.

For example: I have built the XML Parser factory, now to return to the parser itself, let the factory create, return to me. The

xmlparsergetfactory.as
//generates the Factory
class Xmlparsergetfactory implements abstractfactory.{for objects that parse the read XML
Var Xmlparser;
Function Xmlparsergetfactory (str:string) {
//If a message board list parser is required, generates an
if (str== "Xmlparseguestbooklist") {
Xmlparser=new xmlparserguestbooklist ();
}
}
function Createxmlparser () {
//returning the required parser
return xmlparser;
}
}

abstractxmlparser.as
//abstract XML Parser
Interface abstractxmlparser{
Function Parsexml ();
}
xmlparserguestbooklist.as
//Message Board List Resolver
Class xmlparserguestbooklist implements abstractxmlparser{
// Parse the contents of an XML string into a bunch of arrays
function Parsexml (xml:xml,arrayid:array,arraytitle:array) {
//Concrete loop Operation
}
}

When used:
var xmlparser=new xmlparsergetfactory ("Xmlparseguestbooklist")
xmlparser= xmlparsergetfactory. Createxmlparser (Xml,arrayid,arraytitle);

3. Factory approach Mode (Factory method)
I went to the canteen window, if the master and there smoking, I still eat things. I said: Master, dozen Rice! Master will finish the action of rice. This is the factory method pattern, and the implementation of the abstract factory is usually done in the factory method mode.

For example: or the previous one, I was going to use a sentence with a parameter on the implementation of a specific XML parser, but the constructor does not return a value, so you must use
Xmlparser= xmlparsergetfactory. Createxmlparser (Xml,arrayid,arraytitle);
Realize.

Note: Abstract Factory mode, generator pattern and factory method pattern need to be applied flexibly.

4. Single-piece mode (singleton)
I bought a huge chicken leg in front of me, and I said I want one too, said the master.

For example: The application of a single piece mode is quite extensive, it ensures that each instance is only created once in the global scope, our flash in the MC Most is a single piece. The core component in the kernel is also a single piece, such as my message map list (see below).
In accordance with the strict definition of a single piece of mode, the class should be held responsible for saving its unique instance. But I still can't think of how to do this in flash, or what it means, but the other thing we can do is to provide the only access point for that object globally. This can be done by the hierarchical relationship, the access to the object is all encapsulated in the lower level, only to provide a unique access point to the upper layer (because the upper layer does not know the specific information of this single piece, such as the path).
Look at part of my kernel file:
Core.as
Kernel
Class Core {
var strucglobalparam:configvariables;
Site information
var xmlconfig:xml;
XML Object for site information
var Arraystructureinitial:array;
An array to provide to the Loadobject object
var Arrayforbtn:array;
The array used to initialize the navigation bar component
var objinitial:loadobject;
To read a movie's object
var Objmessagemap:messagemap;
Message Mapping Component
......
}
This is my kernel class, which is the most core class data structure of the whole station. The data inside is only accessed directly through classes such as Basicmovie,originalfunctionobject (see below).

Note that the core idea is to make sure there is only one.

5. Prototype mode (PROTOTYPE)
To the Gift window, look at the front of the Brothers fried green peppers fried meat good appearance. "Master, I will do the same." ”

For example: This is familiar to flash users, we often use Duplicatemovieclip () and
Attachmovie () These two functions. Copy the corresponding instances according to a prototype and perform their own actions. In my blog list, the navigation bar is generated. The use of prototype mode is necessary for almost any number of data.

6. Responsibility Chain Model
7. Intermediary model
8. Observer Model
Canteen in the kitchen farthest window did not boil cabbage, to tell the kitchen, quickly sent over.
Responsibility chain mode: A window A window to the word, has been passed to the canteen, the canteen a look bad, hurry to send the past.
Intermediary mode: Dedicated to send a person responsible for the message, any window is no food, it is necessary for this person to hurry to the kitchen.
Observer mode: The kitchen side sends a stare and starts yelling at which window is out of food.

For example: The reason to put these three design patterns together, because I am in my station combined with these three created a fun thing, can be said to be the core of my site. It solves my flash inside each MC's communication problem.
For example, after the movie A is finished, to inform the movie B to start playing, the direct way is to write a relative path from a to B or the absolute path of B in the last frame of a, let B play (). The coupling between A and B is quite high, that is to say, the degree of interdependence is too high. The solution for using design patterns is as follows:

Messagemap.as
Message Map Class
Class Messagemap extends Object {
var message:string;
var messagewatcher:function;
var Target;
var Messagelist:array;
var Num_msg:number;
function Messagemap () {
num_msg = 0;
Messagelist = new Array ();
message = "HANG_UP";
Messagewatcher = function (prop, Oldvar, Newvar, Param) {
for (var i = 0; i<num_msg+1; i++) {
if (Newvar = = Messagelist[i][0]) {
Messagelist[i][1].apply (Messagelist[i][3], messagelist[i][2]);
if (! Messagelist[i][4]) {
Messagelist.splice (i, 1);
num_msg--;
I-=1;
}
}
}

};
This.watch ("message", Messagewatcher, "test");
}
Function SendMessage (msg:string, Mc:movieclip) {
message = MSG;
}
function Updatemessagemap (msg:string, Objfunction:function, Arrayparam:array, Objrefer,ismultiused:boolean) {
MESSAGELIST[NUM_MSG] = new Array ();
Messagelist[num_msg][0] = new String ();
Messagelist[num_msg][0] = MSG;
MESSAGELIST[NUM_MSG][1] = new Function ();
MESSAGELIST[NUM_MSG][1] = objfunction;
MESSAGELIST[NUM_MSG][2] = new Array ();
MESSAGELIST[NUM_MSG][2] = Arrayparam;
MESSAGELIST[NUM_MSG][3] = Objrefer;
MESSAGELIST[NUM_MSG][4] = ismultiused;
num_msg++;
}
function Deletemessagemap (objrefer) {
for (var i = 0; i<num_msg; i++) {
if (messagelist[i][2] = = Objrefer) {
Messagelist.splice (i, 1);
num_msg--;
}
}
}
}

Class Subtemplatemovie extends Basemovie {
var movieremovefunction:function;
function Subtemplatemovie () {
This.stop ();
Moviestartfunction = function () {
Lock ();
This.play ();
};
Movieendfunction = function () {
Lock ();
This.play ();
};

Movieremovefunction = function () {
This.stop ();
Sendmsg ("sub_template_removed", this);
_parent.unloadmovie ();
};
Moviemainfunction = function () {
Stop ();
Sendmsg ("Sub_template_open", this);
};
Updatemessage ("Loading_bar_over", moviestartfunction, NULL, this, false);
Updatemessage ("Back_to_index", movieendfunction, NULL, this, false);
}
}

Presumably the mechanism is that the film submits a data structure ahead of time, stating that if a movie submits this message, it executes the function. The principle is that the message is actually a variable assignment of the message map, because the message map inherits from the object class, you can use the Watch method to monitor the variable, once changed, in the message map has been submitted to check the list, if so, to perform the corresponding function. In fact, this also caused a certain degree of coupling, but we have successfully put the coupling control in the subordinate class, the superior subclass completely ignore this set of message mechanism implementation process.

This mechanism allows us to have a deeper view of the true purpose of OOP. For example, the film a played out, declared that their play finished, as I finished what you want to do, not my business, I do not control you. The so-called reduction of coupling is a relative concept, do not forget at the bottom of the computer, coupling or the same, the CPU is always direct or indirect addressing, but we need to do is to change the system topology, the coupling degree of control within a certain range.

The entire message map class is equivalent to an intermediary that generates an observer internally, and once the message is triggered, it executes in the form of a chain of responsibility.

9. Bridging mode (bridge)
Food is too light, not to some people's appetite, so asked the chef, special open a window, specialized in doing good dishes add some chili.

I used bridge mode in my own station: All movies Inherit the Basicmovie class (Basicmovie inherits from the MovieClip Class), but in four sub columns, you need to define the same methods and events to respond to the message. Basicmovie without these functions, not conforming to the requirements, it is foolish to write them in four films, and I have written a Subtemplatemovie class inherits from Basemovie, adding some common methods, and then four subordinate template movies inherit it, This greatly simplifies the development of the latter.

Basicmovie.as
Base class Movie
/All movie's original class, all the movie's parent class inherits this class to come
Class Basemovie extends MovieClip {
var Islocked:boolean;
Initial class start movie function
var moviestartfunction:function;
Original class movie main function function
var moviemainfunction:function;
Initial class End Movie function
var movieendfunction:function;
var Globalparam
Initial class constructor
function Basemovie () {
}
//

Send a message
function sendmsg (msg:string, Mc:movieclip) {
_root.objcore.objmessagemap.sendmessage (MSG, Mc);
}
To add a message map
function Updatemessage (msg:string, msgmapfunction:function, Arrayparam, obj, ismultiused) {
_root.objcore.objmessagemap.updatemessagemap (MSG, msgmapfunction, Arrayparam, obj, ismultiused);
}
Delete a message map
function Deletemessage (obj) {
_root.objcore.objmessagemap.deletemessagemap (obj);
}
function GetGlobalParam () {
Globalparam=_root.objcore.strucglobalparam;
}
}

Subtemplatemovie.as
Subordinate Template Movie class
Class Subtemplatemovie extends Basemovie {
var movieremovefunction:function;
function Subtemplatemovie () {
This.stop ();
Moviestartfunction = function () {
Lock ();
This.play ();
};
Movieendfunction = function () {
Lock ();
This.play ();
};

Movieremovefunction = function () {
This.stop ();
Sendmsg ("sub_template_removed", this);
_parent.unloadmovie ();
};
Moviemainfunction = function () {
Stop ();
Sendmsg ("Sub_template_open", this);
};
Updatemessage ("Loading_bar_over", moviestartfunction, NULL, this, false);
Updatemessage ("Back_to_index", movieendfunction, NULL, this, false);
}
}
Note (on message mapping mechanism see responsibility chain mode)

10. Adapter Mode (Adapter)
I want a bowl of soup, but only a paper lunch box, not a spoon, so the canteen master gave me a one-time soup bowl and spoon, this is called the adapter.

The adapter solves the problem of the external interface of a class, possibly due to a mismatch between the parameter or the return value type, when we need to add a layer of indirection between the work object and the class.
This pattern I used at the underlying data exchange layer. As I said, the exchange of data between Flash and ASP.net is all based on XML. Back to XML at the bottom only three layers, database operations, data manipulation, data display, by the data operation layer returned to the data display layer an XML string can be. Then I ran into a little problem, on the other hand, I needed to submit the data to the database and also submit an XML string, but I needed the XML representation of the data set of the corresponding table in the database XSD validation! (said at a breath, almost not suffocated). That means I have to at least take out one of the records in this table, the problem is that the class I encapsulate never returns XML, it doesn't return XSD. The workaround is the adapter, create a new project, and add a layer dedicated to obtaining the XML validation format, which completes the transition between the different interfaces.

Note: Adapters and bridges are very much like, when the existing class does not meet the requirements, add a layer of indirect elements to achieve the purpose. The difference is that the adapter is a solution to the conversion between incompatible interfaces, the bridge is generally not involved in this problem, just a one-to-many conversion.

11. Appearance mode (façade)
Every day to go to the canteen, everyone to different window to eat different dishes, very tired, today the whole bedroom to recommend monkeys to play Rice:
You eat this, 32 rice, I eat that, 52 rice, everyone is only with the monkey a person to negotiate, the canteen all the master also saw a monkey a person.

For example: This pattern can be applied very widely between the upper and lower layers of the program's communication. Each module of ASP to go to different data, access the different tables of the database, it is necessary to deal with the different data access components of the lower level. That is, each MC module must know that I am going to the specific data access component to fetch the data. Each module is to maintain one of its own, at least a string.
If you use a skin pattern. We can have all the MC accesses the same ASPX page, such as getstrxml.aspx, that require data interaction. As long as you send an identifier, you can notify the unique data to the surface of the surface, which access to the lower component to obtain data. The lower component does not know which MC requires data, and the MC does not know the specific source of the data, so that the upper and lower layers are opaque to each other. This reduces the degree of coupling.

12. Agent mode (proxy)
Maybe we are not everyone wants to eat every day, so we ask the monkey must be in the dormitory every noon, if we want to eat, he went, if we do not eat, he loves doing why.

For example: This is probably a pattern that everyone will inadvertently use in flash. For example, a Web site, its subordinate columns do not have to start at the beginning of the entire site to read in, but we want to make sure that when the viewer wants to see and clicks on a button on the navigation bar, it can correctly read the corresponding movie file, provided we have to keep an index internally, which can be called an agent. is usually an empty MC

13. Strategy Mode (strategy)
I find a seat in the cafeteria first, then dozen rice, then dozen vegetables, and then buy a cup of yogurt. This has been modeled. If there is a waiter in the canteen, I will ask him to do so.

For example, the strategy pattern is to encapsulate a series of algorithms to form a class. This pattern can be integrated into other modes almost anywhere, my stack of XML parsers is actually the application of the strategy model, which is also applied to the lower level of my site, because the data that flash submits to the ASPX page is also an XML string, and the underlying module needs the corresponding parsing algorithm. In the same way, I encapsulate XML parsing into a class.

Analytic functions in CS files

Class datamodel.blogmsgs{
...
Public DataSet Parsexml (string strxml) {
DataSet ds=new DataSet ();
。。 Load XML into a dataset
Return DS
}
...
}

14. Mode of Flyweight (a)
Not enough food? Give you 20 mirrors ~
Master, there is only one thing ...

I am very sorry about this mode, I have not thought of the implementation of the flash inside. To illustrate, the browser's mechanism is that in English documents with a large amount of text, the same letters share a flyweight, in memory in fact only occupy a space, and then in different places in the document display, so for a large number of fine-grained effects, can save a lot of resources. It would be appreciated if any comrade had thought of it.

15. Visitor Pattern (Visitor)
Whenever I want to, I can run to the window at any time to play something I want to eat, if I have to run this trip.

For example: As I said, all of my MC inherits from the Basicmovie class, but not all of my MC has to get the database data from later. Get the information that the database data wants to access, such as IP, path, file in the configuration file, read into the kernel when initializing, and only have a copy of the kernel. It is not appropriate to include references to these global variables in Basicmovie, because only a handful of them are used, and for some reason I can no longer use the bridging mode (I already have subtemplatemovie and cannot inherit more), so I use the visitor pattern.

Basicmovie.as

Get Global variables
function GetGlobalParam () {
Globalparam=_root.objcore.strucglobalparam;
}

If the superior MC does not perform this function, it cannot get the global variable, and if it is to be used, execute it.
That is to say, when needed, I went to visit it.

Remarks: Declares a visit operation that allows visitors to access the required classes correctly.

16. Status mode (state)
I want to eat noodles today, Master asked me: what material? Tomatoes, eggs, ribs or beef?

For example: A state pattern is the localization of some of the current state of an object, and it looks as if the class changed when the object changes state. Example or my scroll bar. If you want to scroll the text box, you need to refer to a TextField scroll,maxscroll attribute, if the MC, refers to the _y,_height attribute, I use a parameter to distinguish between the two, by an if statement control, so that the scroll bar can be free to distinguish the state.
Another solution is to define the different subclasses of the scrollbar, which are not substantially different, and may have to maintain a large if algorithm for a long state, so that it is better to use the method of generating subclasses.

Scrollbar.as
Scroll bar Component
function BindTo (mc,type:string,intmcheight:number,yinitial:number) {
Scrolltype=type;
if (type== "TXT") {
SCROLLTXT=MC;
}
if (type== "MC") {
initialy=yinitial;
Mcheight=intmcheight;
SCROLLMC=MC;
}
}
function Scroll () {
if (scrolltype== "TXT")
This.onenterframe = function () {
Scrolltxt.scroll = scrolltxt.maxscroll*mcblock._y/(BGLENGTH-BLOCKLENGTH*3/2)
};
if (scrolltype== "MC") {
This.onenterframe=function () {
if (scrollmc._height>mcheight) {
scrollmc._y=initialy-(scrollmc._height-mcheight) *mcblock._y/(BGLENGTH-BLOCKLENGTH*3/2)}
}
}
}

Note: This is also a common pattern, especially in flash logic control.

17. Decoration Mode (decorator)
Eating in the cafeteria, how to do without chopsticks? I never brought a rice bowl. Master is very human, each window is put a lot of chopsticks, with the use.

If you use this model well, some places can be very labor-saving. For example, the scroll bar in my website:

Scrollbar.as
Scroll bar Component
Class ScrollBar extends Basemovie {
var Bglength:number;
var Blocklength:number;
var mcblock:movieclip
var Width:number;
var Scrolltype;
var Scrolltxt:textfield;
var Scrollmc:movieclip;
var mcheight:number
var initialy:number
function ScrollBar () {
}
function Initialscrollbar (bglength, blocklength) {
This. Blocklength = Blocklength;
This. Bglength = Bglength;
}
function BindTo (mc,type:string,intmcheight:number,yinitial:number) {
Scrolltype=type;
if (type== "TXT") {
SCROLLTXT=MC;
}
if (type== "MC") {
initialy=yinitial;
Mcheight=intmcheight;
SCROLLMC=MC;
}
}
function Scroll () {
if (scrolltype== "TXT")
This.onenterframe = function () {
Scrolltxt.scroll = scrolltxt.maxscroll*mcblock._y/(BGLENGTH-BLOCKLENGTH*3/2)
};
if (scrolltype== "MC") {
This.onenterframe=function () {
if (scrollmc._height>mcheight) {
scrollmc._y=initialy-(scrollmc._height-mcheight) *mcblock._y/(BGLENGTH-BLOCKLENGTH*3/2)}
}
}
}
function SCROLLMC () {

}
function Stopscroll () {
This.onenterframe=null;
}
function Reset () {
mcblock._y=0;
}
}

The core function is BindTo (), which binds an instance of this scroll bar to a dynamic text box or to an MC to enable scrolling.

Note: The idea of decorative mode is to add responsibilities to a single object in a dynamic, transparent manner without affecting other objects.

18. Combination Mode (composite)
I eat 62 meals a noon, pork stew vermicelli, spicy chicken, fish balls, salted duck eggs, plus two cups of yogurt (pig!) )
They were all objects, and they made up my lunch together.

For example: it should be said that in the Flash combination mode is ubiquitous, because as long as there is the MC nesting, there is a combination of patterns exist. A few MC in a MC, the load of the MC called a container.
But that said, I'm afraid no one will pay attention to this model, because not management does not understand him we are using. He does have a lot of ways to achieve it, and one of my ways is this.

Blog.as
My blog
Class Blog extends Basemovie {
Blog first interface, including diary list, calendar, recent message
var mcbloglist:mcbloglist;
Blog second interface, including the full text of the diary, reply, the diary of the message.
var Mcblogdairy:movieclip;
var currentstate:string;
var Currentdairyid:number;
function blog () {
}
}

Mcbloglist.as
Blog First Interface
Class Mcbloglist extends Basemovie {
Recent messages
var recentmsgs:blogmsgssc;
Journal List
var bloglist:bloglist;
Calendar
var Calendar:calenderforblog;


Mcblogdairy.as
Blog Second Interface
Class Mcblogdairy extends Basemovie {
Journal Full text display
var Blogdairy:blogdairy;
Walls
var guestbook:bloginputmsg;
Message list Display
var blogmsgs:blogmsgs;
}

And then each component contains another component, such as a scroll bar, dynamic text box What I want to say is that I write in as as in the MC nested pattern does not necessarily conform to the FLA file in the specific physical nesting mode, there are many decorative MC does not need to include, there are many specific reasons, need to rewrite the path. For example, in the Blogdairy, the actual path of the scroll bar is BlogDairy.mc1.ScrollBar, not made Blogdairy.scrollbar may be because I need MC1 animation, but also may be other specific reasons. But we can add a sentence on the MC1 timeline.
_parent. ScrollBar =this.scrollbar
The path to rewrite, to achieve the pattern we want to use, ScrollBar is a direct member of the Blogdairy. In addition I do not have the statement initialization MC, I am accustomed to set up the MC linkage in the library.

Note: Although the combination mode is essential for everyone to use, but because of this, we can come up with his more and better and more flexible way of implementation

19. Memo Mode (Memento)
~ Master, the chicken leg of the night is not fresh at noon.
~ Nonsense! This is the noon.

For example: A joke, the above two words is not the meaning of the memo mode, in fact, I can't think of a memo in the cafeteria what it looks like. The memo means to save the current state of the object without damaging the encapsulated type of the object, and to restore the state or extract the state when needed.

The memo is widely used in a logical relationship, and it seems to be the only time-related pattern I've mentioned at the moment, which can involve causal systems in cybernetics. The memo is very widely used, the most common is the browser or the back of the Web site function, back to the previous interface, but in my station is not used, because my station is a tree topology, each column can only be from the main interface to enter or return to the main interface, those network topology structure of the site, Each column can lead to any other column, it is likely to need such a function, its implementation method is often to maintain a stack type of array.

Another thing I want to achieve is the internal automatic recording of the site, for some reason I did not add it to the site for the time being. Very simple, is to monitor the browser every step of the operation, in which column, how long to stop, what to do, and so on, if left, the next time to visit the site let him choose whether to go directly to the last browsing interface (such as his last read the novel I wrote and did not read). This can be achieved by sharedobject, which is almost the cookie inside of Flash.

Note: Memo implementation requirements are still very high, in the extraction of object states do not destroy the encapsulation of the object. The ideal memo as an object needs two excuses, one to the manager, it does not know what the memo encapsulated in the state, only responsible for the state to the desired object, a left to the original, the original person can only understand and operation of the encapsulation of the status of the memo, can not do other operations.

Summary:
I will add this article at any time. But some of the examples that I have to cite have been done for the time being. In fact, the design pattern is far more than these, there are 23 classic, I know there are 41 kinds, and there are only 19 kinds, there are command mode, interpreter mode, iterator mode, template method mode I did not write. My station also used some I did not mention, I have not thought of the design pattern. But the list is actually not meaningful, interested comrades have to do is to contact the details of these design patterns and ideas, and then all forget, and Zhang Mowgli to learn Taijiquan, first learn after forgetting is the same. Move to see, to learn, but to understand the deep meaning of the, flexible, creative, mutual combination, mastery of the use of moves, not rigidly adhere to the moves, but not to use strokes. As an important part of UML, design pattern can greatly promote our development efficiency, make us develop good writing habits, make more human, more harmonious, clearer, more complex and more controllable works.
Do not say that you are not a programmer, you can follow the feeling go, arbitrary, of course, we have no right to interfere. I also said, as originally is how to write on how to write, but not contact, learn not to learn advanced thinking mode, this is your freedom. Not to mention that you're an artist, the mind is sensitive, not suitable to contact these, I want to incidentally take the canteen for example, is to explain, I want to say is actually on Christian Alexander, building the eternal way, whether the building itself, or any software engineering, or Flash as, Even flash vector graphics, art, graphic design, all the way to the world this whole, is to follow a structured, by the pattern of the eternal Road, has a surprisingly high degree of similarity and similarities. Ponder this point, not only to do flash, for the whole life will have a new view. The difference is just where to start thinking, where you can start with flash.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.