473,385 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Factory Method / Prototype Design Pattern

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
4 4988
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
8
by: Ed Fair | last post by:
Hi, I'm a long-time C programmer, I've started making the transition to "real C++" recently. I am puzzled about how to write a factory method. Any suggestions, pointers or references to...
2
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the...
4
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site...
11
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns....
1
by: David Bellot | last post by:
Hi, if I consider the Factory Method design pattern, then I should have the following objects: Object and ObjectFactory which are usually abstract classes Then for each subclasses like...
10
by: sunny | last post by:
Does this following program implement the factory design.if not what are things that i have to change in order to make this following program to be designed to factory design pattern. ...
1
by: =?Utf-8?B?RXJpYw==?= | last post by:
I am using the factory method to solve a problem where a factory can produce product. I have a base factory class and a base product class. The problem that I am having is that for every product...
2
by: Duy Lam | last post by:
Hi everyone, Sorry, I don't know what group to post this problem, I think may be this group is suitable. I'm styduing DAO (Data Access Object) pattern in this link...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.