Posts Tagged ‘Design Pattern’

Design Patterns in ActionScript-Mediator

My-Documents-256x256 Ok, the last pattern now. Let’s take a look the intent directly.

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

– By THE GOF BOOK

From this intent, we can get that this pattern is use for encapsulating the interaction of objects.

(more…)

Design Patterns in ActionScript-Command

insurance-256x256 A few months ago, I was an intern of a company. I joined a group which builds a LBS application, and our target platform including J2ME and Android. I was asked to make a J2ME demo.

This demo was just like the Google map on J2ME. Eh, actually, we did something more than that; but you don’t need to know, just considering we’re going to build a Google map on J2ME platform.
(more…)

Design Patterns in ActionScript-Chain of Responsibility

FTP-Client-128x128 When you need some help in a hotel, you may ask the attendant firstly, if the attend can’t help you, then the attendant may pass you question to the assistant manager, if the attendant still can’t help you, then the question maybe pass to the lobby manager.

(more…)

Design Patterns in ActionScript-Flyweight

In Action Script 3.0 we have the following ways to define a String.

var str1:String = new String(”foo”);
var str2:String = “foo”;
var str3:String = String(”foo”);

I don’t know which way is your way, but they work the same way. Actually, all of the three String variables point to the same String object in memory. That’s to say there is only one copy of “foo” object in the memory, but three references. In other languages, such as java, are almost the same. It saves the memory. This is called object pool. And there is a similar pattern called Flyweight.

Let’s take a look at its intent.

(more…)

Design Patterns in ActionScript-Visitor

crab-128x128 It’s our winter holiday now, and I spend many times in playing games. In last week, I soaked myself in <Prince of Persia: the sands of time>. I love this game, but it’s a pity for me that when I fight to the monsters, I can’t control the heroine. Because of that sometimes I need her help to shot somebody exactly not the other one. OK, I’m crazy :) Controlling two roles will increase the difficulty of manipulation, and it’s not a RTS game.

(more…)

Design Patterns in ActionScript-Memento

Rhetenor-Morpho-128x128 Now, I’m using Microsoft word to write these articles. These word processor programs are very useful when you writing something down. Sometimes, we heard someone was very familiar with these programs, such as word, can remember many short-cuts. Though I use this program frequently, I can’t remember many short-cuts. I can remember some short-cuts, such as “Ctrl+Z”, which means UNDO.

(more…)

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()”

(more…)

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.

(more…)