Builder pattern seem to suit my requirements perfectly except in one
case
as described below.
I have used the same example diagram that is used in GOF Design
pattern book, to explain the problem that I am facing.
aClient aDirector
aConcreteBuilder
================================================== ===========================
- new ConcreteBuilder-------------------------------------------->
- new Director(aConcreteBuilder)-------->
- Construct()--------------------------->BuildPartA()------------>
BuildPartB()------------>
BuildPartC()------------>
- GetResult()---------------------------------------------------->
There is no problem in calling BuildPartA(), BuildPartB(),
BuildPartC() as a part of Construct(), for all the ConcreteBuilders.
But, apart from that, one additional function(it is different for each
ConcreteBuilder...different in type and number of arguments) needs to
be called for which aClient has to pass different number&type of
arguments depending on the ConcreteBuilder type.
How do you overcome such a scenario?
Does Builder pattern fit here? Or, do you suggest some other pattern
for this?
Do you find some flaw in the design? And, what are the improvements
that you suggest here?