Prototype: Duplicate, Then Change

When "the same as last week, new address" is made by copying a shipment field by field, the copying code forgets whatever was added since; letting the shipment copy itself fixes that, as long as the copy doesn't share its list of boxes with the original, the bug that shallow and deep copies are about.

By

Updated

Cheat sheet: Prototype: Duplicate, Then Change
Category
Data Structures
Level
Apprentice
Tags
Deep Copy, OOP, Prototype Pattern, Shallow Copy