|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
V
- The type of object to be created or destroyed.public interface FactoryIfc<V>
Defines the "Gang of Four" Factory 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," p107 Design
Patterns - Elements of Reusable Object-Oriented Software. Also, as a factory
can create objects, it must too be able to clean up those objects (via the
destroy()
method).
public final class Person { private String _name; private int _age; public Person () { } public String getName () { return _name; } public void setName ( final String name ) { _name = name; } public int getAge () { return _age; } public void setAge ( final String age ) { _age = age; } } public final class PersonFactory implements FactoryIfc <Person> { public Person create () { return new Person (); } public void destroy () { } }Essentially, to implement a factory, do the following:
Person
above).
FactoryIfc
and provde
the generic type for FactoryIfc
(for instance
implements FactoryIfc <Person>
above).
Modifications: $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $ $Revision: 479 $ $Author: sfloess $ $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/gof/factory/FactoryIfc.java $
Method Summary | |
---|---|
V |
create()
Creates a new object. |
void |
destroy(V object)
Destroys (or cleans up) object created by self. |
Method Detail |
---|
V create()
void destroy(V object)
object
created by self.
object
- The object to destroy/clean-up.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |