org.perfectjpattern.core.api.creational.factorymethod
Interface IFactoryMethod<T>
- Type Parameters:
T
- Type of elements created.
public interface IFactoryMethod<T>
Factory Method Design Pattern: Define an interface for creating an
object, but let subclasses decide which class to instantiate.
Factory Method lets a class defer instantiation to subclasses.
(Gamma et al, Design Patterns)
Responsibility Abstract definition of the "Creator":
- Declares the factory method, which returns an object of type
Product.
- Creator may also define a default implementation of the factory
method that returns a default ConcreteProduct object.
may call the factory method to create a Product object.
Example usage:
import org.perfectjpattern.core.api.creational.factorymethod.*;
//
// Example of Factory Method subtype that creates Product with a
// name parameter.
//
public IProductFactory
extends IFactoryMethod<Product>
{
//--------------------------------------------------------------------
// public
//--------------------------------------------------------------------
public void
setName(String aName);
}
- Version:
- $Revision: 1.0 $ $Date: Jun 19, 2007 11:01:51 PM $
- Author:
- Giovanni Azua
-
-
Method Summary |
T |
create()
Returns newly created instance |
create
T create()
- Returns newly created instance
- Returns:
- Newly created instance
Copyright © 2007-2009. All Rights Reserved.