By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,497 Members | 2,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,497 IT Pros & Developers. It's quick & easy.

Factory Method / Prototype Design Pattern

P: n/a
Hi ,

when should i select Factory Method / Prototype Design Pattern
during my design phase ??
as both look similar to me

Thanks in Advance

Thanks
Pallav
Nov 18 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Nov 18, 8:29*am, Pallav singh <singh.pal...@gmail.comwrote:
Hi ,

when should i select * Factory Method / Prototype *Design Pattern
during my design phase ??
as both look similar to me

Thanks in Advance

Thanks
Pallav
IMHO, you should find a pattern for a problem and not a problem to a
pattern
Nov 18 '08 #2

P: n/a
On Nov 18, 1:29*pm, Pallav singh <singh.pal...@gmail.comwrote:
Hi ,

when should i select * Factory Method / Prototype *Design Pattern
during my design phase ??
as both look similar to me
Factory Method creates a new object. Normally, it invokes a (non-copy)
constructor of a concrete implementation class.

Prototype create a new object as a copy of the prototype object. It is
often implemented as clone() member function that invokes the copy
constructor of a concrete implementation class.

You use Factory Method when you want new objects, prototype when you
want copies of existing objects.

--
Max
Nov 18 '08 #3

P: n/a
On Nov 18, 6:36*pm, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
On Nov 18, 1:29*pm, Pallav singh <singh.pal...@gmail.comwrote:
Hi ,
when should i select * Factory Method / Prototype *Design Pattern
during my design phase ??
as both look similar to me

Factory Method creates a new object. Normally, it invokes a (non-copy)
constructor of a concrete implementation class.

Prototype create a new object as a copy of the prototype object. It is
often implemented as clone() member function that invokes the copy
constructor of a concrete implementation class.

You use Factory Method when you want new objects, prototype when you
want copies of existing objects.

--
Max
Hi

i could not make any diffrence from implementation provided by Huston
Design pattern
http://www.vincehuston.org/dp/

from Gang of Four i got Idea to use under Certain Condition

1. Factory
A class hierarchy of factories that parallels the class hierarchy
of products
Parallel class hierarchies result when a class delegates some of
its responsibilities
to a separate class.

2. Prototype

when instances of a class can have one of only a few different
combinations
of state. It may be more convenient to install a corresponding
number of
prototypes and clone them rather than instantiating the class
manually,
each time with the appropriate state.

Does it mean that i should we protoype when i have to make object
at Run Time
depending upon different combinations of state ???

Thanks
Pallav
Nov 18 '08 #4

P: n/a
On Nov 18, 2:11*pm, Pallav singh <singh.pal...@gmail.comwrote:
On Nov 18, 6:36*pm, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
On Nov 18, 1:29*pm, Pallav singh <singh.pal...@gmail.comwrote:
Hi ,
when should i select * Factory Method / Prototype *Design Pattern
during my design phase ??
as both look similar to me
Factory Method creates a new object. Normally, it invokes a (non-copy)
constructor of a concrete implementation class.
Prototype create a new object as a copy of the prototype object. It is
often implemented as clone() member function that invokes the copy
constructor of a concrete implementation class.
You use Factory Method when you want new objects, prototype when you
want copies of existing objects.
--
Max

Hi

i could not make any diffrence from implementation provided by Huston
Design patternhttp://www.vincehuston.org/dp/

from Gang of Four i got Idea to use under Certain Condition

1. Factory
* *A class hierarchy of factories that parallels the class hierarchy
of products
* *Parallel class hierarchies result when a class delegates some of
its responsibilities
* *to a separate class.
In the original question you mentioned Factory Method design pattern.
Now you are quoting Factory. Huh?
>
2. Prototype

* *when instances of a class can have one of only a few different
combinations
* *of state. It may be more convenient to install a corresponding
number of
* *prototypes and clone them rather than instantiating the class
manually,
* *each time with the appropriate state.

* *Does it mean that i should we protoype when i have to make object
at Run Time
* *depending upon different combinations *of state ???
It depends on the problem at hand. Do you have a concrete problem in
mind?

--
Max
Nov 18 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.