A software design pattern organizing how software objects are created. A prototype pattern creates an object by asking an existing example to copy itself, letting a client choose a concrete configuration at runtime through an object interface.
Provide an interface for creating a family of related products while hiding their concrete software classes. Unlike a single factory method pattern operation returning one product abstraction, an abstract factory typically exposes several related product-creation operations whose implementations coordinate a consistent family.
Declare a creation operation returning an abstract product interface and let concrete creators specialize how products are built. Clients call the creator interface rather than hard-coding construction of each concrete product. For example two regional manufacturers can implement
build(carType): Car to select a concrete car and apply regional settings; optional wrappers can then be composed independently using the decorator pattern.Provide a shared unique instance of a service or state holder. A Scala
object supplies one instance of that object definition; a top-level object can therefore centralize shared state such as a registry of current scores. A singleton does not by itself implement thread safety, remove stale entries, or define the lifetime of registered objects. Those remain separate design responsibilities.Expose a cloning operation through a common object interface and create new objects by asking a configured prototype for a copy. Concrete prototypes implement the copy operation; the client need not name their concrete software classes. This is useful when creation depends on runtime configuration or expensive reusable initial state. The contract must specify whether nested mutable data requires a deep copy; copying only outer fields can preserve unintended reference aliasing.
Articles by others on the same topic
There are currently no matching articles.