Gof Prototype

Prototype in modern Java: producing a new object from an existing instance's state, when the configuration is expensive or the concrete type is unknown to the caller. Covers why Cloneable/clone() needs an explicit contract and what replaces it, the deep-versus-shallow decision on graphs with identity and cycles, when immutable values can be shared, the torn-copy hazard under concurrency, and the identity rules when copying persisted objects. Use when clone() or Cloneable appears, when an object is duplicated by serialising and deserialising it, when a configured template must be instantiated many times, when a JPA entity is copied with its id still set, or when a "copy" turns out to share a mutable list with its original. Does not cover constructing from parameters (gof-builder), selecting a type to create (gof-factory-method), sharing rather than copying (gof-flyweight), or snapshot semantics for undo (gof-memento).

robsonkades a207ce6 4 files · 32.6 KB Updated

File contents

robsonkades/agent-skills/tree/main/skills/gof-prototype commit a207ce6d89

Frequently asked questions

npx skillmds@latest add robsonkades/gof-prototype