• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Factory Method and Builder

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the fundamental differance between a Factory method and a builder pattern
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Could you give me a link/reference for Builder Pattern?Then may be I can compare and let you know the difference between the two.
Thanks,
Sandeep
SCJP2,OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sandeep - Go to www.hillside.net/patterns.
There you will find links to UML class diagrams for most of the major design patterns.
Regards, Guy
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that soden't work because of the '.' at the end.
Try:
http://www.hillside.net/patterns/patterns.html
Guy
 
Ganesh Ram
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sandeep,
Take the following scenario.
I am building a Logging component to be used by our system.
I have a class MLog which provides a write and a read method and many other methods too.
I have a Abstract class MLogLine which provides a parse and generate method.
And many extensions of the abstract class viz xLogLine, yLogLine etc.. for each kind of log file.
A user say would create a xLogline and call the write method of MLog.
This creation of the Log line from the object would be partially implemented by xLogline and the other part by mLogLine.
When a user has a line from the log file and would like to parse it, the read of MLog is called.
Internally the read would call a static method from MLogLine that reads the line and instantiates the appropriate xLogLine and returns it back to the user.

Now what pattern is the scenario using. Is it builder??
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ganesh,
Will get back to you as soon as I find something concrete on this.
Thanks,
Sandeep
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I can't understand exactly ur problem problem. I think Design Patterns by Gang of Four is a good refrence for this discussion. But i can help u in difeerence. Difference lies in construcrtion process of both patterns.
Factory Method eliminates the need to bind application specific classess into your code. It supports parallel class hierarchies for frameworks and creates objects in one shot. While Builder Pattern allow you to build differnt kind of objects from differnt parts in step by step construction process.
Suppose we want to develop a window based drawing application system that will be supported on different platforms. For this implementation we have two classess

and

To support this Application to different platfrom one can define a concrete Window class for that platform and concrete DrawingApplication class that implements only createWindow to initialize w1. Abstract method createWindow defers only Window object creation to it subclassess which is platform dependent while doing all the work using w1. This supports parallell class hierarchies with consistent types (interfaces).
In contrast to this Builders decouple building and representation and construct object in step by step process. Suppose we are building generic compiler classess. One way to do this


Compilers with dtfferent Inetrmediate forms can create concrete subclassess for Builder and like TreeBuilder, DagBuilder, TreeArrayBuilder to create Intermediate form.
If we make Parser class an abstract class then differnt Translators for SGML, HTML and other languages can use these Bulders by implementing readNextToken() according to their token representation to produce IntermediateForms. If these IntermediateForms supports same interface then u can also implement Visitor and Iterator Pattern for them to build intermediate two or three address codes and sysntax tree.... More fun
I think This helps
Tahir Mansoori
SCJP2 91%
IBM OOA&D 92%
 
Ganesh Ram
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic