Saturday, November 12, 2011

OODesign - Design Pattern 3 (Creational pattern)

Ref: http://www.oodesign.com/design-principles.html

Singleton Pattern [easy]
> Ensure that only one instance of a class is created.
> Provide a global point of access to the object.
(example: Cairngorm's Model Locator)


Factory Pattern[easy]
> creates objects without exposing the instantiation logic to the client.
> refers to the newly created object through a common interface
(example: drawingCanvas.mxml, creation of drawingTool)



Factory Method Pattern
> Defines an interface for creating objects, but let subclasses to decide which class to instantiate
> Refers to the newly created object through a common interface
(AbstractDrawingTool(abstract); TextTool, LineTool(concrete Product); redraw(), set Text() (factory method))


Abstract Factory
> Abstract Factory offers the interface for creating a family of related objects, without explicitly specifying their classes.


Builder Pattern
[easy]
> Defines an instance for creating an object but letting subclasses decide which class to instantiate
> Refers to the newly created object through a common interface


Prototype Pattern [easy]
> specifying the kind of objects to create using a prototypical instance
> creating new objects by copying this prototype

Object Pool [easy]
> reuse and share objects that are expensive to create
(example: connection pool)
.

No comments:

Post a Comment