Object-oriented programming: Difference between revisions

Content deleted Content added
Design patterns: Moved info from object (computer science)
Line 237:
 
==Design patterns==
 
ChallengesOne way to address challenges of object-oriented design are addressed by several approaches. The most common is knownvia as the [[Design Patterns (book)|design patterns codified by Gamma ''et al.'']]. More broadly, the term "[[design pattern (computer science)|design patterns]]" canwhich be used to refer to any general, repeatable,are solution patternpatterns to a commonly occurring problemproblems in software design. Some of these commonly occurring problems have implications and solutions particular to object-oriented development.
 
===Object patterns===
 
The following are notable [[software design pattern]]s for OOP objects.<ref name="R.C.Martin">{{cite web |url=http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf |title=Design Principles and Design Patterns |last=Martin |first=Robert C. |author-link=Robert Cecil Martin |access-date=28 April 2017 |url-status=dead |archive-url=https://web.archive.org/web/20150906155800/http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf |archive-date=September 6, 2015 }}</ref>
 
*[[Function object]]: with a single method (in C++, the function operator, <code>operator()</code>) it acts much like a function
 
*[[Immutable object]]: does not change state after creation
 
*[[First-class object]]: can be used without restriction
 
*[[Container (data structure)|Container object]]: contains other objects
 
*[[Factory object]]: creates other objects
 
*[[Metaobject]]: from which other objects can be created (compare with a [[class (computer science)|class]], which is not necessarily an object)
 
*[[Prototype pattern|Prototype object]]: a specialized metaobject from which other objects can be created by copying
 
*[[God object]]: knows or does too much; example of an [[anti-pattern]]
 
*[[Singleton pattern|Singleton object]]: only instance of its class for the lifetime of the program
 
*[[Filter object]]: receives a stream of data as its input and transforms it into the object's output
 
===Inheritance and behavioral subtyping===