This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi All, I just started reading the Java Design pattern & referred the following url for understanding the Prototype Design pattern. (http://www.fluffycat.com/java/JavaNotes-GoFPrototype.html) But I am not sure whether will we use this pattern for the given usage(i.e for creating soupspoons, saladspoons in that example. I think we can directly instantiate the soupspoons and saladspoons). Can you please clarify the prototype usage. My Observation for prototype pattern usage is: If i want to have a copy of the instance then i can use the prototype pattern. For that i have to get the clone of object by implementing Clonable interface and calling the clone method then serialize & deserialize the result object to get the copy of the given instance. Am I right? What is the advantage of doing so? Thanks & Regards, M.S.Raman.
YOu wrote: For that i have to get the clone of object by implementing Clonable interface and calling the clone method then serialize & deserialize the result object to get the copy of the given instance. Am I right? I don't think you need the serialization step. Just calling "clone" should be enough. There is some discussion of the "prototype" pattern in this old thread which may help clear things up a bit.