Content deleted Content added
Stevebroshar (talk | contribs) →Features: we don't need to list stuff that isn't OOP in the OOP article |
Stevebroshar (talk | contribs) →Objects: Composition is a feature |
||
Line 110:
The OOP features provided by languages varies. Below are some common features of OOP languages.<ref name="ArmstrongQuarks">Deborah J. Armstrong. ''The Quarks of Object-Oriented Development''. A survey of nearly 40 years of computing literature identified several fundamental concepts found in the large majority of definitions of OOP, in descending order of popularity: Inheritance, Object, Class, Encapsulation, Method, Message Passing, Polymorphism, and Abstraction.</ref><ref>[[John C. Mitchell]], ''Concepts in programming languages'', Cambridge University Press, 2003, {{ISBN|0-521-78098-5}}, p.278. Lists: Dynamic dispatch, abstraction, subtype polymorphism, and inheritance.</ref><ref>Michael Lee Scott, ''Programming language pragmatics'', Edition 2, Morgan Kaufmann, 2006, {{ISBN|0-12-633951-1}}, p. 470. Lists encapsulation, inheritance, and dynamic dispatch.</ref><ref name="pierce">{{Cite book|last=Pierce|first=Benjamin|title=Types and Programming Languages|publisher=MIT Press|year=2002|isbn=978-0-262-16209-8|title-link=Types and Programming Languages}}, section 18.1 "What is Object-Oriented Programming?" Lists: Dynamic dispatch, encapsulation or multi-methods (multiple dispatch), subtype polymorphism, inheritance or delegation, open recursion ("this"/"self")</ref> Comparing OOP with other styles, like [[relational programming]], is difficult because there isn't a clear, agreed-upon definition of OOP.<ref name="DatePage650">C. J. Date, Introduction to Database Systems, 6th-ed., Page 650</ref>
===
An object consists of [[Field (computer science)| fields]] and [[Method (computer programming)| method]]s. A field (a.k.a. attribute or property) holds information (a.k.a. state) as a [[variable (computer science)| variable]]. A method (a.k.a. [[function (programming)| function]] or action) defines behavior via logic code. Objects are usually stored in [[Memory address| memory]].
Objects can contain other objects. This is called [[object composition]]. For example, an Employee object might have an Address object inside it, along with other information like "first_name" and "position". This type of structures shows "has-a" relationships, like "an employee has an address".▼
====Real-world modeling and relationships====
Line 136 ⟶ 130:
However, more often, objects represent abstract entities, like an open file or a unit converter. Not everyone agrees that OOP makes it easy to copy the real world exactly or that doing so is even necessary. [[Robert C. Martin|Bob Martin]] suggests that because classes are software, their relationships don't match the real-world relationships they represent.<ref>{{cite web |url=https://www.youtube.com/watch?v=zHiWqnTWsn4 |title=Uncle Bob SOLID principles |website=[[YouTube]] |date=2 August 2018}}</ref> [[Bertrand Meyer]] argues in ''[[Object-Oriented Software Construction]]'', that a program is not a model of the world but a model of some part of the world; "Reality is a cousin twice removed".{{sfn|Meyer|1997|p=230}} [[Steve Yegge]] noted that natural languages lack the OOP approach of strictly prioritizing ''things'' (objects/[[noun]]s) before ''actions'' (methods/[[verb]]s), as opposed to [[functional programming]] which does the reverse.<ref name="executioniKoN">{{Cite web| first = Steve| last=Yegge |title = Execution in the Kingdom of Nouns| date=30 March 2006|access-date=3 July 2010| publisher = steve-yegge.blogspot.com| url=http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html}}</ref> This can sometimes make OOP solutions more complicated than those written in procedural programming.<ref name="executioniKoN2">{{Cite web| first = Timothy| last= Boronczyk |title = What's Wrong with OOP| date=11 June 2009|access-date=3 July 2010| publisher = zaemis.blogspot.com| url=http://zaemis.blogspot.com/2009/06/whats-wrong-with-oop.html}}</ref>
===Composition===
▲
===Inheritance===
|