Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about "design pattern"

Status
Not open for further replies.

zhuzhengyu

Technical User
Jul 21, 2000
19
CN
hope someone could give me advice:
there are two simaliar creation pattern,say "abstract factory"&"factory method".I think they all contain two kinds of classes:
"creating class" used to create
"created class" used to be created

both need to be inherited to concrete class.
and only the "concrete creating class" could create "concrete created class"

I know the dipiction is clumsy.But hope to find the difference of them.

thanks a lot [sig][/sig]
 
If i understand the pattern right, remembering i only started learning about design patterns a few months ago, an abstract factory is an abstract class that sets out the framework with factory methods which can be abstract or concrete either way they're generally over-written by the child class. A factory method generates a object. how this is done is usually determined by the concrete class but the parameters and object types are set out by the abstract factory.

anybody with a better understanding of this design patterns want to correct me? [sig]<p>Chris Packham<br><a href=mailto:kriz@i4free.co.nz>kriz@i4free.co.nz</a><br><a href= > </a><br>A thousand mokeys at a thousand machines, it happened, it got called the internet.[/sig]
 
My understanding of both patterns is as follow:
1- Abstract factory

Create the right factory for a familly of object usually based on passed argument(s).

2- Factory

Create the right object from a familly of object (again usually based on passed argument(s))

Hugues
 
If you are designing a system where by you have a number of obejcts which are created by factory objects, you may create either a factory super class, which all other factory classes inherit from, or a factory interface class which all factories must implement. Using this will gaurantee that developers creating the factoy implement methods (i.e. ones for transaction management).

The same goes for the created objects of you system. It is good design to have all the objects inheriting from one base class which has certain methods which all class can use. Also this will help from the polymporhism end whereby you can perform methods on all the objects in your system by casting them to the base class.

I know this is a bit muddled....lowsy long hours!

Cal


 
These patterns probably find their widest application in object serialization. Java has object serialization built in as part of the VM. So... that raises the question of why you are interested in these patterns, or, how do you intend to use them?

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top