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%