The Artima Developer Community
Sponsored Link

Design Forum
What is prototype design pattern?

7 replies on 1 page. Most recent reply: Oct 31, 2009 1:07 PM by pavel ipotpalski

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 7 replies on 1 page
Amit

Posts: 23
Nickname: amitactsh
Registered: Nov, 2002

What is prototype design pattern? Posted: Nov 18, 2004 12:57 AM
Reply to this message Reply
Advertisement
Could anyone please explain what the prototype design pattern exactly is for and how and where is it implemented ?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: What is prototype design pattern? Posted: Nov 19, 2004 10:09 AM
Reply to this message Reply
http://www.google.com/search?q=prototype+design+patternd

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: What is prototype design pattern? Posted: Nov 19, 2004 10:13 AM
Reply to this message Reply
Oops, accidentally rested my finger a little too heavily on the D key; that should have been:

http://www.google.com/search?q=prototype+design+pattern

Hey Bill, I just thought of a nifty feature for Artima Answers Forums: in addition to the post, you could automatically submit the subject to Google and include the list of the first few links with the post (maybe in a side box or something). I better contact a patent lawyer about this right away...

Rajagopal

Posts: 3
Nickname: rajagopaly
Registered: Mar, 2005

Re: What is prototype design pattern? Posted: Mar 15, 2005 9:38 PM
Reply to this message Reply
Prototype pattern implies cloning of an object rather than creation. If the cost of creating a new object is large and creation is resource intensive, we clone the object. We use Cloneable interface and call it¡¦s clone() method on the object we want to clone.

Starts with an initialized and instantiated class and clones it to make new instances rather than creating new instances.

The Prototype pattern allows an object to create customized objects without knowing
their exact class or the details of how to create them. It specifies the kinds of objects to
create using a prototypical instance, and creates new objects by copying this prototype.
The Prototype pattern works by giving prototypical objects to an object and then initiates
the creation of objects. The creation-initiating object then creates objects by asking the
prototypical objects to make copies of themselves. The Prototype pattern makes creating
objects dynamically easier by defining classes whose objects can duplicate themselves.

The benefits of using the Prototype pattern:
„Ï Adding and removing products at run time
„Ï Specifying new objects by varying values
„Ï Specifying new objects by varying structure
„Ï Reduced subclassing
„Ï Configuring an application with classes dynamically

We should use the Prototype pattern when:
„Ï The classes to instantiate are specified at run time, for example, by dynamic
loading.
„Ï To avoid building a class hierarchy of factories that parallels the class hierarchy of products.
„Ï When instances of a class can have one of only a few different combinations of
state.

Steven Lee

Posts: 1
Nickname: steve22
Registered: May, 2007

Re: What is prototype design pattern? Posted: May 29, 2007 9:28 PM
Reply to this message Reply
You can find a good explanation here
http://ehsanbraindump.blogspot.com/2007/05/prototype.html

Anusha Naveen

Posts: 5
Nickname: ashwork
Registered: Jul, 2007

Re: What is prototype design pattern? Posted: Jul 30, 2007 12:26 AM
Reply to this message Reply
A prototype pattern is a creation design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. This pattern is used for example when the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) is prohibitively expensive for a given application.

Asaf Me

Posts: 1
Nickname: asafm
Registered: Jan, 2009

Re: What is prototype design pattern? Posted: Jan 10, 2009 10:27 AM
Reply to this message Reply
You wrote:
> „Ï To avoid building a class hierarchy of factories that
> parallels the class hierarchy of products.

I also read it in the Design Pattern book.

I failed to find an example for it. I mean, finding a case where I'll need to create a lot of factories classes, which the Prototype pattern will save me from doing so.

Thank you,

Asaf

pavel ipotpalski

Posts: 1
Nickname: ipotpal
Registered: Oct, 2009

Re: What is prototype design pattern? Posted: Oct 31, 2009 1:07 PM
Reply to this message Reply
http://www.apwebco.com/gofpatterns/creational/Prototype.html
Check this link

Flat View: This topic has 7 replies on 1 page
Topic: Web application design pattern using only stored procedures ,NO Dynamic SQL Previous Topic   Next Topic Topic: Finding the best architecture n design for..

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use