...

/

Replicating Complex Objects

Replicating Complex Objects

Learn which design patterns to use when we need several copies of a complex object.

Problem statement

Let’s imagine that we have an object that we need to copy multiple times. Because it’s not a primitive type, we can’t just copy the value of the whole thing into a new variable of the same kind. Instead, we’d need to instantiate a new object of this type and then copy the value of every field from the original object instance.

That would be fine for ...