Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Creational pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Usage== As modern software engineering depends more on [[object composition]] than class inheritance, emphasis shifts away from hard-coding behaviors toward defining a smaller set of basic behaviors that can be composed into more complex ones.<ref>{{cite book|title=Design Patterns|year=1995|publisher=Addison-Wesley|location=Massachusetts|isbn=978-0-201-63361-0|last1=Gamma|first1=Erich|last2=Helm|first2=Richard|last3=Johnson|first3=Ralph|last4=Vlissides|first4=John|page=[https://archive.org/details/designpatternsel00gamm/page/84 84]|access-date=2015-05-22|url=https://archive.org/details/designpatternsel00gamm/page/84}}</ref> Hard-coding behaviors are inflexible because they require overriding or re-implementing the whole thing in order to change parts of the design. Additionally, hard-coding does not promote reuse and makes it difficult to keep track of errors. For these reasons, creational patterns are more useful than hard-coding behaviors. Creational patterns make design become more flexible. They provide different ways to remove explicit references in the concrete classes from the code that needs to instantiate them.<ref>{{cite book|title=Design Patterns|year=1995|publisher=Addison-Wesley|location=Massachusetts|isbn=978-0-201-63361-0|last1=Gamma|first1=Erich|last2=Helm|first2=Richard|last3=Johnson|first3=Ralph|last4=Vlissides|first4=John|page=[https://archive.org/details/designpatternsel00gamm/page/85 85]|access-date=2015-05-22|url=https://archive.org/details/designpatternsel00gamm/page/85}}</ref> In other words, they create independency for objects and classes. Consider applying creational patterns when: * A system should be independent of how its objects and products are created. * A set of related objects is designed to be used together. * Hiding the implementations of a class library or product, revealing only their interfaces. * Constructing different representation of independent complex objects. * A class wants its subclass to implement the object it creates. * The class instantiations are specified at run-time. * There must be a single instance and client can access this instance at all times. * Instance should be extensible without being modified.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)