Archive for the ‘Design Patterns’ Category

Design Patterns in Action Script-Composite

toad-256x256 Still remember the Interpreter example? No matter what you type is a number or an expression; it can calculate the result just by the clause” new GeneralExpression(inputText.text).interpret()”


Design Patterns in ActionScript-Interpreter

Feeding-cattle-256x256 In web programming, we often use regular expression for validating the e-mail address or phone number. Regular expression is a powerful tool in validating the specific format field. However, the interpretation of regular expression is not an easy job.

In the GoF’s design patterns, there is a corresponding pattern named Interpreter.


Design Patterns in ActionScript-Proxy

aim-128x128Have you ever use HTTP-proxy or some other proxy? When you’re in a relatively isolated environment, such as the LAN in your company, maybe you’ll need it. Actually, when I was an intern in an IT company, I always used the HTTP-proxy to login the MSN and surf on the internet. When I used MSN or surf on the net, I can’t feel the existence of the proxy. And this is the role of a proxy. And this can be express as follows.


Design Patterns in Action Script-State

RinoCeronte-256x256 Yesterday, when I was on my way home, I suddenly met an old friend. I haven’t met him since I began to write these articles. :) We stop at a little cafe, and began to talk.

“I’ve just changed my job”, he said, “and now I join the Orange”.

“WOW, Orange, you mean the biggest MP3 manufacturer company,” I answered.

“Yeah, and I join the new product team, we want to surprise the whole world by our new product.” He said proudly.

……. (The rest of our conversation is very boring, so, let’s stop here)


Design Patterns in ActionScript-Builder

Box-Full-128x128 Have you ever buy a computer online, maybe from dell? In dell’s website, we just need to follow its process to order the accessories you need, then you can get your own computer configuration. Of course, you can’t get the real computer until you pay it :)

Here, you direct the producer to produce your own computer through the dell website. Ok, three roles here, you, dell website and the real producer.


Design Patterns in ActionScript-Prototype

aquarium-128x128 When I want to write the Prototype pattern, I firstly look up the ActionScript 3.0 manual. I want to find out whether there is a clone method in Object class. If so, I will use this as an example. But, unfortunately, I can’t find this method in the Object class. Then I found the prototype attribute, but the explanation confused me. So, I decide to show you this pattern in my own way without using the Object class.

Firstly, you need to know the intent of this pattern. You can read the following text.


Design Patterns in ActionScript-Iterator

chat-japonais-256x256 There is a famous saying in computer science, “Program = Data Structure + Algorithm”. It figures out the importance of how to organize the data and how to deal with the data.

Maybe, in your applications, you care more about how to show the data, because this has much to do with the user experience. However, how to organize the data and deal with the data is also or much more important, because this has much to do with the performance.


Design Patterns in Action Script-Template Method

cat-3-256x256 Do you like playing cards? If your had ever played, you may noticed that everyone has their own way arranging the cards. And in most cases, people will put the cards in order, maybe from the biggest one to the smallest one. Eh, this is a way of sorting.

We can write down the following code to mimic this action.