Tuesday, October 19, 2010

Dunebuggyblueprints.com

Design Pattern: Factory Method Design Pattern

Factory Method
The Factory Method is a creational pattern, used for the instantiation of resources from a single access point, the best resource to start using it and look wikipedia.

The basic logic of the Factory Method is to provide an interface for creating an object.
Let's create a simple Factory, we start with our product:

class Product {
public String name;}

then with our interface that returns a product:
public interface Factory
{public abstract Product getProdotto ();
}
and finally the real class that actually produces the product:
FactoryImpl public class Factory implements {public
getProdotto Product () {
return new Product ();}
}

A customer who wants to use our will on the one subject a Server Factory and call the method getProdotto () to get a real instance.

The real code is here

0 comments:

Post a Comment