Design Patterns in ActionScript-Final Note

dory-256x256 In this series, we talk about the 23 design patterns. We use some examples to illustrate how and when to use the patterns, but there is still something I’ve to say here.

Why design patterns?

In my view, design pattern is just a solution to some types of problems, and just a general solution. We use this pattern is just because this pattern is proved to be useful or efficiency to this kind of problem. In general, it’s a better solution, maybe not the best one, but it’s enough in most cases.

With these patterns, you can communicate with your colleagues more easily during the development. You just need to say the pattern name, such as “Singleton”, and your colleagues will understand, “Oh, it’s a singleton, I can’t use the new operator.” You don’t need to explain to your colleagues what the pattern it is.

How and when to use the patterns?

It depends on your experience and what the problem is. Understanding the problem is the first step and the most important step when you build an application.

The following is the conclusion from the GoF book, maybe it helps you.

Abstract Factory

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

http://ntt.cc/2008/10/19/gang-of-four-gof-design-patterns-in-actionscript-abstract-factory.html

Builder

Separate the construction of a complex object from its representation so that the same construction process can create different representations.

http://ntt.cc/2009/01/22/gang-of-four-gof-design-patterns-in-actionscript-builder.html

Factory Method

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

http://ntt.cc/2008/10/08/gang-of-four-gof-design-patterns-in-actionscript-factory-method.html

Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

http://ntt.cc/2009/01/21/gang-of-four-gof-design-patterns-in-actionscript-prototype.html

Singleton

Ensure a class only has one instance, and provide a global point of access to it.

http://ntt.cc/2009/01/12/gang-of-four-gof-design-patterns-in-actionscript-singleton.html

Adapter

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.

http://ntt.cc/2008/10/28/gang-of-four-gof-design-patterns-in-actionscript-adapter.html

Bridge

Decouple an abstraction from its implementation so that the two can vary independently.

http://ntt.cc/2009/01/11/gang-of-four-gof-design-patterns-in-actionscript-bridge.html

Composite

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

http://ntt.cc/2009/01/30/gang-of-four-gof-design-patterns-in-actionscript-composite.html

Decorator

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

http://ntt.cc/2008/11/01/gang-of-four-gof-design-patterns-in-actionscript-decorator.html

Facade

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

http://ntt.cc/2009/01/10/gang-of-four-gof-design-patterns-in-actionscript-facade.html

Flyweight

Use sharing to support large numbers of fine-grained objects efficiently.

http://ntt.cc/2009/02/05/gang-of-four-gof-design-patterns-in-actionscript-flyweight.html

Proxy

Provide a surrogate or placeholder for another object to control access to it.

http://ntt.cc/2009/01/25/gang-of-four-gof-design-patterns-in-actionscript-proxy.html

Chain of Responsibility

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

http://ntt.cc/2009/02/06/gang-of-four-gof-design-patterns-in-actionscript-chain-of-responsibility.html

Command

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

http://ntt.cc/2009/02/09/gang-of-four-gof-design-patterns-in-actionscript-command.html

Interpreter

Given a language, define a represention for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

http://ntt.cc/2009/01/27/gang-of-four-gof-design-patterns-in-actionscript-interpreter.html

Iterator

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

http://ntt.cc/2009/01/18/gang-of-four-gof-design-patterns-in-actionscript-iterator.html

Mediator

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.

http://ntt.cc/2009/02/10/gang-of-four-gof-design-patterns-in-actionscript-mediator.html

Memento

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later.

http://ntt.cc/2009/02/01/gang-of-four-gof-design-patterns-in-actionscript-memento.html

Observer

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

http://ntt.cc/2009/01/13/gang-of-four-gof-design-patterns-in-actionscript-observer.html

State

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.

http://ntt.cc/2009/01/25/gang-of-four-gof-design-patterns-in-actionscript-state.html

Strategy

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

http://ntt.cc/2008/10/07/gang-of-four-gof-design-patterns-in-actionscript-strategy.html

Template Method

Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.

http://ntt.cc/2009/01/16/gang-of-four-gof-design-patterns-in-actionscript-template-method.html

Visitor

Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

http://ntt.cc/2009/02/03/gang-of-four-gof-design-patterns-in-actionscript-visitor.html

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can leave a response, or trackback from your own site.

5 Responses to “Design Patterns in ActionScript-Final Note”

  1. stef says:

    thanks for a wonderful contribution to the community.

    next time you are in montreal let me know and i will buy you more than one beer.

    stef

  2. Luciano says:

    And In buenos aires too.!
    You deserve it!

    Luciano

  3. [...] Design Patterns in ActionScript-Final Note [...]

  4. Bas says:

    And in Amsterdam – lots of beers!
    Thanks many…

    Bas

Leave a Reply