Posts filed under 'Creational patterns'
The prototype means making a clone. This implies cloning of an object to avoid creation. If the cost of creating a new object is large and creation is resource intensive, we clone the object. This article explains how this pattern can be used in coldfusion
I set out tonight to determine if the Prototype design pattern would be useful in object factories in ColdFusion 8. The Prototype pattern, in a nutshell, is to create a new instance of an object by copying an existing object instantiation. The object to copy is an object instantiated once and then used as a blueprint for future objects of the same type. The thought is that copying an object holds a lesser cost than instantiating a new object.
Read the full Article
Tags: cf, coldfusion, design pattern, prototype pattern
December 26th, 2007
Factory method pattern implementation in coldfusion along with working sample code, This pattern helps to model an interface for creating an object which at creation time can let its subclasses decide which class to instantiate.
For those of you new to this concept, an object factory is nothing but a component whose sole job is to create components. An object factory is quite simple and small. Its main role is to collect the information necessary to create an instance of the intended object’s class and then to invoke that class’s constructor
Read the full Article
Tags: cf, coldfusion, design pattern, factory pattern
December 16th, 2007
Coldfusion implementation of singleton pattern to restrict instantiation of class to one object. Singleton Pattern is useful when exactly one object is needed to coordinate actions across the system. Sometimes it is generalized to systems that operate more efficiently when only one or a few objects exist
Singletons are perhaps one of the most simple Design Patterns. For those who don’t know sigletons are a class that can only have one instance. They can be thought of as a glorified global variable - but are a lot more useful.
Read the full Article
Tags: cf, coldfusion, design pattern, singleton pattern
November 27th, 2007