From Design Pattern by Gang of Four,
Example:
Why doesn't the interface Builder
have a method GetResult()
, which is overridden in the concrete class ConcreteBuilder
?
In the example, the concrete builders have GetXXX()
methods, where XXX
is different for different concrete builders, which doesn't promote "programming to interface" at all.
Is this "omission" deliberate in the builder pattern?
Yes, the omission is deliberate. The book addresses it directly.
Regarding the comments to the OP, generics could assist the client in handling products by enabling a
GetResult()
method with a generic return type in theBuilder
interface.