Question

Out of 5 creational design, would Builder and Prototype mixture be a valid use?

The reason for this question is - Builder assists building complex objects with various combinations of attributes. But Prototype ensures that a reference object can be cloned so that expensive (and more frequent) object creations can reference a blueprint (and yes, it actually doesn't save the call to new as sometime's it's claimed rather infamously)

This means (rather correctly, or incorrectly inferred by myself) that A builder could actually use a prototype of a complex object and build clones as and when it is required? Or, they are strictly mutually exclusive?

Was it helpful?

Solution

You are completely right: creational patterns are not all mutually exclusive.

The builder intends to let a Director build a complex object. This may involve the creation of simpler parts that need to be assembled in the building process.

The parts may therefore very well be build using another creational pattern such as a factory or a prototype.

Licensed under: CC-BY-SA with attribution
scroll top