• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Examples for Builder and ProtoType

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone let me know, where could i find the examples
for Builder and ProtoType pattern.

Your help is highly appreciated.

Regards
Prathap.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java clone() method is an example of the prototype pattern. the definition of prototype is: "Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype". This is what the java clone() method does.
 
Sujatha Kumar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i have an example for a Builder.

Regards
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Builder definition from Gang of 4 - Separate the construction of a complex object from its representation so that the same construction process can create different representations.

Here is a link:
http://www.fact-index.com/b/bu/builder_pattern.html

Some of the creational patterns are a little blurry to me. I created a class called ArraySQL that allows you to type in a sql string and I parse that String to create the appropriate objects behind the scenes. The developer that uses my class has no idea what objects I create from there request. I think that fits the builder pattern as described above, but most examples don't use parsed Strings to build objects on the fly, so I'm not sure if it is the builder pattern or not.

Here is an example of ArraySQL. Note that different objects are created behind the scenes depending on whether a display column is a function or wha t type of where clause is being used i.e. in, =, <=, != etc.

 
Pay attention! Tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic