Content deleted Content added
Stevebroshar (talk | contribs) Get to the point; remove fluff |
typo |
||
(28 intermediate revisions by 5 users not shown) | |||
Line 1:
{{short description|Programming paradigm based on
{{Use dmy dates|date=January 2020}}
[[File:Oop-uml-class-example.svg|frame|right|[[UML]] notation for a class. This Button class has [[Variable (computer science)|variables]] for data, and [[Method (computer programming)|functions]]. Through inheritance, a subclass can be created as a subset of the Button class. Objects are instances of a class.]]
'''Object-oriented programming''' ('''OOP''') is a [[programming paradigm]] based on the [[Object (computer science)|object]]<ref name=alanKayOnOO
|year=2011
|title=Object-Oriented Simulation of systems with sophisticated control
|journal=International Journal of General Systems
|
|issue=3
|pages=313–343 |doi=10.1080/03081079.2010.539975
}}</ref><ref>{{Cite book |last1=Lewis |first1=John |last2=Loftus |first2=William |year=2008 |chapter=1.6: Object-Oriented Programming |title=Java Software Solutions |series=Foundations of Programming Design |edition=6th |publisher=Pearson Education Inc. |isbn=978-0-321-53205-3}}</ref> A [[programming language]] that provides OOP features is classified as an ''OOP language'' but as the set of features that contribute to OOP is contended, classifying a language as OOP and the degree to which it supports or is OOP, are debatable. As paradigms are not mutually exclusive, a language can be [[multi-paradigm]]; can be categorized as more than only OOP.
Sometimes, objects represent real-world things and processes in digital form.<ref>{{cite book |last1=Booch |first1=Grady |author1-link=Grady Booch |year=1986 |title=Software Engineering with Ada |publisher=Addison Wesley |isbn=978-0-8053-0608-8 |page=220 |url=https://en.wikiquote.org/wiki/Grady_Booch |quote=Perhaps the greatest strength of an object-oriented approach to development is that it offers a mechanism that captures a model of the real world.}}</ref> For example, a graphics program may have objects such as {{code|circle}}, {{code|square}}, and {{code|menu}}. An online shopping system might have objects such as {{code|shopping cart}}, {{code|customer}}, and {{code|product}}. [[Niklaus Wirth]] said, "This paradigm [OOP] closely reflects the structure of systems in the real world and is therefore well suited to model complex systems with complex behavior".<ref>{{cite journal
|last1=Wirth |first1=Niklaus |author1-link=Niklaus Wirth
|journal=[[IEEE Computer]]
|volume=39
|issue=1
|date=January 23, 2006
|pages=28–39
|title=Good ideas, through the looking glass
|series=Cover Feature
|doi=10.1109/MC.2006.20
|s2cid=6582369
|url=https://pdfs.semanticscholar.org/10bd/dc49b85196aaa6715dd46843d9dcffa38358.pdf |archive-url=https://web.archive.org/web/20161012215755/https://pdfs.semanticscholar.org/10bd/dc49b85196aaa6715dd46843d9dcffa38358.pdf |url-status=dead |archive-date=12 October 2016
}}</ref>
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 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 language]]s lack the OOP approach of naming a thing (object) before an action (method), as opposed to [[functional programming]] which does the reverse.<ref name="executioniKoN">{{Cite web |last1=Yegge |first1=Steve |date=30 March 2006 |title=Execution in the Kingdom of Nouns |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 make an OOP solution more complex than one written via [[procedural programming]].<ref name="executioniKoN2">{{Cite web |last1=Boronczyk |first1=Timothy |date=11 June 2009 |title=What's Wrong with OOP |url=http://zaemis.blogspot.com/2009/06/whats-wrong-with-oop.html |publisher=zaemis.blogspot.com |access-date=3 July 2010}}</ref>
Notable languages with OOP support include [[Ada (programming language)|Ada]], [[ActionScript]], [[C++]], [[Common Lisp]], [[C Sharp (programming language)|C#]], [[Dart (programming language)|Dart]], [[Eiffel (programming language)|Eiffel]], [[Fortran]] 2003, [[Haxe]], [[Java (programming language)|Java]],{{sfn|Bloch|2018|loc=Foreword|pp=xi-xii}} [[JavaScript]], [[Kotlin (programming language)|Kotlin]], [[Logo (programming language)|Logo]], [[MATLAB]], [[Objective-C]], [[Object Pascal]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[R (programming language)|R]], [[Raku (programming language)|Raku]], [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[SIMSCRIPT]], [[Simula]], [[Smalltalk]], [[Swift (programming language)|Swift]], [[Vala (programming language)|Vala]] and [[Visual Basic (.NET)]].
==History==
The idea of "objects" in programming
|last1=McCarthy
|first1=John
|author1-link=John McCarthy (computer scientist)
|last2=Abrahams
|first2=Paul W.
|last3=Edwards
|first3=Daniel J.
|last4=Hart
|first4=Swapnil D.
|last5=Levin
|first5=Michael I.
|year=1962
|url=https://archive.org/details/lisp15programmer00john/page/105
|title=LISP 1.5 Programmer's Manual
|publisher=[[MIT Press]]
|page=[https://archive.org/details/lisp15programmer00john/page/105 105]
|isbn=978-0-262-13011-0
|quote=Object – a synonym for atomic symbol
|df=dmy-all
}}</ref>
Another early example was [[Sketchpad]] created by [[Ivan Sutherland]] at MIT in 1960–1961. In the glossary of his technical report, Sutherland defined terms like "object" and "instance" (with the class concept covered by "master" or "definition"), albeit specialized to graphical interaction.<ref>{{cite conference
Line 49 ⟶ 63:
|pages=329–346
|doi=10.1145/1461551.1461591|doi-access=free}}
</ref> Later, in 1968, AED-0, MIT's version of the [[ALGOL]] programming language,
|last1=Nygaard |first1=Kristen |author1-link=Kristen Nygaard
|last2=Dahl |first2=Ole-Johan |author2-link=Ole-Johan Dahl
|date=August 1, 1978
|title=The development of the SIMULA languages
|journal=[[ACM SIGPLAN Notices]]
|volume=13
Line 59 ⟶ 74:
|doi=10.1145/960118.808391
|doi-access=free
}}
</ref><ref>
{{Cite web
</ref>
Topics such as [[data abstraction]] and [[modular programming]] were common points of discussion at this time.
Meanwhile, in Norway, [[Simula]] was developed during the years 1961–1967.<ref name=simuladev/> Simula introduced essential object-oriented ideas, such as [[Class (computer programming)|classes]], inheritance, and [[Dynamic binding (computing)|dynamic binding]].<ref name="auto">{{Cite journal|
Simula was used mainly by researchers involved with [[physical modelling]], like the movement of ships and their content through cargo ports.<ref name="auto"/> Simula is generally accepted as being the first language with the primary features and framework of an object-oriented language.<ref>{{cite journal |last1=Madsen |first1=Ole Lehrman |title=Kristen Nygaard |journal=A.M. Turing Award Laureates |url=https://amturing.acm.org/award_winners/nygaard_5916220.cfm |access-date=4 February 2025}}</ref>
{{Quote box
|quote
|author
|source
|width
}}
Influenced by both MIT and Simula, [[Alan Kay]] began developing his own ideas in November 1966. He would go on to create [[Smalltalk]], an influential
A 1976 MIT memo co-authored by [[Barbara Liskov]] lists [[Simula 67]], [[CLU (programming language)|CLU]], and [[Alphard (programming language)|Alphard]] as object-oriented languages, but does not mention Smalltalk.<ref>{{cite tech report |
In the 1970s, the first version of the [[Smalltalk]] programming language was developed at [[Xerox PARC]] by [[Alan Kay]], [[Dan Ingalls]] and [[Adele Goldberg (computer scientist)|Adele Goldberg]]. Smalltalk-72 was notable for use of objects at the language level and its graphical development environment.<ref name="Bertrand Meyer 2009 329">{{Cite book|title=Touch of Class: Learning to Program Well with Objects and Contracts|author=Bertrand Meyer|publisher=Springer Science & Business Media|year=2009|isbn=978-3-540-92144-8|pages=329|bibcode=2009tclp.book.....M}}</ref> Smalltalk was a fully dynamic system, allowing users to create and modify classes as they worked.<ref>{{cite journal
Line 93 ⟶ 107:
|pages=69–95
|date=March 1993
|doi=
|doi-access=free
}}
</ref> Much of the theory of OOP was developed in the context of Smalltalk, for example multiple inheritance.<ref>{{cite report |last1=Borning |first1=Alan Hamilton |date=1979 |title=Thinglab
In the late 1970s and 1980s,
In the mid-1980s, new object-oriented languages like [[Objective-C]], [[C++]], and [[Eiffel language|Eiffel]] emerged. Objective-C was developed by [[Brad Cox]], who had used Smalltalk at [[ITT Inc.]] [[Bjarne Stroustrup]] created [[C++]] based on his experience using Simula for his PhD thesis.<ref name="Bertrand Meyer 2009 329"/> [[Bertrand Meyer]] produced the first design of the [[Eiffel language]] in 1985, which focused on software quality using a [[design by contract]] approach.{{sfn|Meyer|1997}}
In the 1990s,
At [[ETH Zürich]], [[Niklaus Wirth]] and his colleagues created new approaches to OOP. [[Modula-2]] (1978) and [[Oberon (programming language)|Oberon]] (1987), included a distinctive approach to object orientation, classes, and type checking across module boundaries. Inheritance is not obvious in Wirth's design since his nomenclature looks in the opposite direction: It is called type extension and the viewpoint is from the parent down to the inheritor.
Many programming languages that
==Features==
{{Anchor|Object-oriented source code}}
{{See also|Comparison of programming languages (object-oriented programming)|List of object-oriented programming terms}}
===
An object [[Encapsulation (computer programming)|encapsulates]] [[Field (computer science) |fields]] and [[Method (computer programming) |method]]s. A field (a.k.a. attribute or property) contains 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. Encapsulation is about keeping [[Cohesion (computer science)|related]], code together.
===Information hiding===
[[Information hiding]] is organizing code so that it is accessible only to the code that needs it; not to the rest of the [[codebase]]. The internal details of an object are hidden from the outside code, allowing for changing how an object works without affecting its interface and therefore other code. Hiding information helps prevent problems when changing the code.<ref>{{Cite book |last1=McDonough |first1=James E. |title=Object-Oriented Design with ABAP: A Practical Approach |date=2017 |publisher=[[Apress]] |isbn=978-1-4842-2837-1 |___location= |chapter=Encapsulation |doi=10.1007/978-1-4842-2838-8 |via=[[O'Reilly Media|O'Reilly]]}}</ref> Objects act as a barrier between their internal workings and external, consuming code. Consuming code can only interact with an object via its public members.
Some programming languages, like Java, provide information hiding via visibility key words ({{code|private}} and {{code|public}}).{{sfn|Bloch|2018|loc=Chapter §4 Item15 Minimize the accessibility of classes and members|pp=73-77}} Some languages don't provide a visibility feature, but developers might follow a convention such as starting a private member name with an underscore. Intermediate levels of access also exist, such as Java's {{code|protected}} keyword, (which allows access from the same class and its subclasses, but not objects of a different class), and the {{code|internal}} keyword in C#, Swift, and Kotlin, which restricts access to files within the same module.<ref>{{Cite web |date=2023-01-05 |title=What is Object Oriented Programming (OOP) In Simple Words? – Software Geek Bytes |url=https://softwaregeekbytes.com/object-oriented-programming-simple-words/ |access-date=2023-01-17 |language=en-US}}{{Dead link|date=July 2025 |bot=InternetArchiveBot |fix-attempted=yes}}</ref>
Supporters of information hiding and data abstraction say it makes code easier to reuse and intuitively represents real-world situations.<ref name="Luca1985">{{Cite journal |last1=Cardelli |first1=Luca |last2=Wegner |first2=Peter |date=1985-12-10 |title=On understanding types, data abstraction, and polymorphism |journal=ACM Computing Surveys |language=en |volume=17 |issue=4 |pages=471–523 |doi=10.1145/6041.6042 |issn=0360-0300|doi-access=free}}</ref><ref>{{cite book|last1=Jacobsen|first1=Ivar|title=Object Oriented Software Engineering|year=1992|publisher=Addison-Wesley ACM Press|isbn=978-0-201-54435-0|pages=[https://archive.org/details/objectorientedso00jaco/page/43 43–69]|author2=Magnus Christerson|author3=Patrik Jonsson|author4=Gunnar Overgaard|url=https://archive.org/details/objectorientedso00jaco/page/43}}</ref> However, others argue that OOP does not enhance readability or modularity.<ref name="badprop"/><ref name="armstrongjoe"/> [[Eric S. Raymond]] has written that OOP languages tend to encourage thickly layered programs that destroy transparency.<ref name="Eric S. Raymond 2003">{{cite web|url=http://www.catb.org/esr/writings/taoup/html/unix_and_oo.html|title=The Art of Unix Programming: Unix and Object-Oriented Languages|last1=Raymond|first1=Eric S.|date=2003|access-date=6 August 2014}}</ref> Raymond compares this unfavourably to the approach taken with [[Unix]] and the [[C (programming language)|C]] language.<ref name="Eric S. Raymond 2003"/>
[[SOLID]] includes the [[open/closed principle]], which says that classes and functions should be "open for extension, but closed for modification". [[Luca Cardelli]] has stated that OOP languages have "extremely poor modularity properties with respect to class extension and modification", and tend to be extremely complex.<ref name="badprop"/> The latter point is reiterated by [[Joe Armstrong (programmer)|Joe Armstrong]], the principal inventor of [[Erlang (programming language)|Erlang]], who is quoted as saying:<ref name="armstrongjoe">{{cite book |last1=Armstrong |first1=Joe |author1-link=Joe Armstrong (programmer) |editor1-last=Seibel |editor1-first=Peter |title=Coders at Work: Reflections on the Craft of Programming |url=http://www.codersatwork.com/ |publisher=Codersatwork.com |archive-url=https://web.archive.org/web/20100305165150/http://www.codersatwork.com/ |archive-date=5 March 2010 |access-date=13 November 2009}}</ref>
{{Blockquote|The problem with object-oriented languages is they've got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.}}
Leo Brodie says that information hiding can lead to [[duplicate code]],<ref>{{Cite book |last1=Brodie |first1=Leo |year=1984 |url=https://thinking-forth.sourceforge.net/thinking-forth-ans.pdf |title=Thinking Forth |pages=92–93 |access-date=4 May 2018}}</ref> which goes against the [[don't repeat yourself]] rule of software development.<ref>{{cite web |work=Category Extreme Programming |last1=Hunt |first1=Andrew |url=http://wiki.c2.com/?DontRepeatYourself |title=Don't Repeat Yourself |access-date=4 May 2018}}</ref>
===Composition===
Via [[object composition]], an object can contain other objects. For example, an {{code|Employee}} object might contain an {{code|Address}} object, along with other information like {{code|name}} and {{code|position}}. Composition is a "has-a" relationships, like "an employee has an address".
===Inheritance===
====
In [[class-based programming]], the most common type of OOP,
* [[Class variable]] – belongs to the class itself; all objects of the class share one copy
* [[Instance variable]] – belongs to an object; every object has its own version of these variables
* [[Member variable]] – refers to both the class and instance variables of a class
* Class method – can only use class variables
* Instance method – belongs to an objects; can use both instance and class variables
Classes may inherit from other classes, creating a hierarchy of classes: a case of a subclass inheriting from a super-class. For example, an {{code|Employee}} class might inherit from a {{code|Person}} class which endows the Employee object with the variables from {{code|Person}}. The subclass may add variables and methods that do not affect the super-class. Most languages also allow the subclass to override super-class methods. Some languages support [[multiple inheritance]], where a class can inherit from more than one class, and other languages similarly support [[mixin]]s or [[Trait (computer programming)|traits]]. For example, a mixin called UnicodeConversionMixin might add a method unicode_to_ascii() to both a FileReader and a WebPageScraper class.
An [[abstract class]] cannot be directly instantiated as an object. It is only used as a super-class.
====
Instead of providing a class concept, in [[prototype-based programming]], an object is linked to another object, called its ''prototype'' or ''parent''. In Self, an object may have multiple or no parents,<ref>{{cite book |chapter=Classifying prototype-based programming languages|chapter-url=https://www.lirmm.fr/~dony/postscript/proto-book.pdf|first1=C|last1=Dony|first2=J|last2=Malenfant|first3=D|last3=Bardon|title=Prototype-based programming: concepts, languages and applications |date=1999 |publisher=Springer |___location=Singapore Berlin Heidelberg |isbn=9789814021258}}</ref> but in the most popular prototype-based language, [[JavaScript]], an object has exactly one prototype link, up to the base object whose prototype is null.
A prototype acts as a model for new objects. For example, if you have an object {{code|fruit}}, you can make two objects {{code|apple}} and {{code|orange}} that share traits of the {{code|fruit}} prototype. Prototype-based languages also allow objects to have their own unique properties, so the {{code|apple}} object might have an attribute {{code|sugar_content}}, while the {{code|orange}} or {{code|fruit}} objects do not.
====No inheritance====
Some languages, like [[Go (programming language)|Go]], don't support inheritance.<ref>{{Cite web |url=https://golang.org/doc/faq#Is_Go_an_object-oriented_language |title=Is Go an object-oriented language? |access-date=April 13, 2019 |quote=Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy.}}</ref> Instead, they encourage "[[composition over inheritance]]", where objects are built using smaller parts instead of parent-child relationships. For example, instead of inheriting from class Person, the Employee class could simply contain a Person object. This lets the Employee class control how much of Person it exposes to other parts of the program. [[Delegation (object-oriented programming)|Delegation]] is another language feature that can be used as an alternative to inheritance.
Programmers have different opinions on inheritance. Bjarne Stroustrup, author of C++, has stated that it is possible to do OOP without inheritance.<ref>{{cite conference |last1=Stroustrup |first1=Bjarne |author1-link=Bjarne Stroustrup |title=Object-Oriented Programming without Inheritance (Invited Talk) |date=2015 |doi=10.4230/LIPIcs.ECOOP.2015.1 |doi-access=free |url=https://www.youtube.com/watch?v=xcpSLRpOMJM |conference=29th European Conference on Object-Oriented Programming (ECOOP 2015) |at=1:34}}</ref> [[Rob Pike]] has criticized inheritance for creating complex hierarchies instead of simpler solutions.<ref>{{cite web |url=http://plus.google.com/+RobPikeTheHuman/posts/hoJdanihKwb |title=A few years ago I saw this page |last1=Pike |first1=Rob |access-date=1 October 2016 |date=14 November 2012|archive-url=https://web.archive.org/web/20180814173134/http://plus.google.com/+RobPikeTheHuman/posts/hoJdanihKwb |archive-date=14 August 2018}}</ref>
====Inheritance and behavioral subtyping====
People often think that if one class inherits from another, it means the subclass "[[is a]]" more specific version of the original class. This presumes the [[program semantics]] are that objects from the subclass can always replace objects from the original class without problems. This concept is known as [[behavioral subtyping]], more specifically the [[Liskov substitution principle]].
Line 191 ⟶ 181:
===Dynamic dispatch===
A method may be invoked via [[dynamic dispatch]] such that the method is selected at runtime instead of compile time. If the method choice depends on more than one type of object (such as other objects passed as parameters), it's called [[multiple dispatch]].
Dynamic dispatch works together with inheritance: if an object doesn't have the requested method, it looks up to its parent class ([[Delegation (object-oriented programming)|delegation]]), and continues up the chain to find a matching method.
===Message passing===
[[Message passing]] is when the method name and its inputs are sent like a message to the object for it to act on.
===Polymorphism===
[[Polymorphism (computer science)|Polymorphism]]
For example, imagine a program has two shapes: a circle and a square. Both come from a common class called "Shape." Each shape has its own way of drawing itself. With subtype polymorphism, the program doesn't need to know the type of each shape, and can simply call the "Draw" method for each shape. The programming language runtime will ensure the correct version of the "Draw" method runs for each shape. Because the details of each shape are handled inside their own classes, this makes the code simpler and more organized, enabling strong [[separation of concerns]].
Line 217 ⟶ 195:
===Open recursion===
==Design patterns==
[[Design pattern (computer science)|Design patterns]] are common solutions to problems in software design. Some design patterns are especially useful for
===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 |
*[[Function object]]: Class with one main method that acts like an [[anonymous function]] (in C++, the function operator,
*[[Immutable object]]: does not change state after creation
*[[First-class object]]: can be used without restriction
Line 279 ⟶ 219:
{{Main|Design pattern (computer science)}}
''[[Design Patterns: Elements of Reusable Object-Oriented Software]]'' is a famous book published in 1994 by four authors: [[Erich Gamma]], [[Richard Helm]], [[Ralph Johnson (computer scientist)|Ralph Johnson]], and [[John Vlissides]]. People often call them the "Gang of Four". The book talks about the strengths and weaknesses of
These solutions, called "design patterns," are grouped into three types:
Line 290 ⟶ 230:
{{Main|Object-relational impedance mismatch|Object-relational mapping|Object database}}
Both
To solve this problem, developers use different methods, but none of them are perfect.<ref name="RDMDBobjectmis">{{Cite web
Some databases, called [[object database]]s, are designed to work with
Date and Darwen have proposed a theoretical foundation that uses OOP as a kind of customizable [[data type|type system]] to support RDBMSs, but it forbids objects containing pointers to other objects.<ref name="ThirdManifesto">C. J. Date, Hugh Darwen. ''Foundation for Future Database Systems: The Third Manifesto'' (2nd Edition)</ref>
Line 310 ⟶ 250:
* [[Dependency inversion principle]]: Depend upon abstractions, not concretes.
[[GRASP (object-oriented design)|GRASP]] (General Responsibility Assignment Software Patterns) is another set of software design rules, created by [[Craig Larman]], that helps developers assign responsibilities to different parts of a program:<ref>{{Cite web |
* Creator Principle: allows classes create objects they closely use.
Line 321 ⟶ 261:
==Formal semantics==
Researchers have tried to formally define the [[Semantics (computer science)|semantics]] of OOP. [[Inheritance (object-oriented programming)|Inheritance]] presents difficulties, particularly with the interactions between open recursion and encapsulated state. Researchers have used [[recursive type]]s and [[F-Coalgebra|co-algebraic data types]] to incorporate essential features of OOP.<ref name=poll97>{{cite web|last1=Poll|first1=Erik|title=Subtyping and Inheritance for Categorical Datatypes|url=https://www.cs.ru.nl/E.Poll/papers/kyoto97.pdf|access-date=5 June 2011}}</ref> Abadi and Cardelli defined several extensions of [[System F-sub|System F<sub><:</sub>]] that deal with mutable objects, allowing both [[subtype polymorphism]] and [[parametric polymorphism]] (generics), and were able to formally model many OOP concepts and constructs.<ref name="AbadiCardelli">{{Cite book |first1=Martin |last1=Abadi |title=A Theory of Objects |url=http://portal.acm.org/citation.cfm?id=547964&dl=ACM&coll=portal |year=1996 |access-date=21 April 2010 |isbn=978-0-387-94775-4 |publisher=Springer-Verlag New York, Inc. |author-link=Martin Abadi|author2=Cardelli, Luca}}</ref> Although far from trivial, static analysis of object-oriented programming languages such as Java is a mature field,<ref>{{cite conference |last1=Tan |first1=Tian |last2=Li |first2=Yue |date=12 July 2023 |title=Tai-e: A Developer-Friendly Static Analysis Framework for Java by Harnessing the Good Designs of Classics|conference=ISSTA 2023 |pages=1093–1105 |doi=10.1145/3597926.3598120}}</ref> with several commercial tools.<ref>{{cite journal |last1=Bhutani |first1=Vikram |last2=Toosi |first2=Farshad Ghassemi |last3=Buckley |first3=Jim |date=1 June 2024 |title=Analysing the Analysers: An Investigation of Source Code Analysis Tools |journal=Applied Computer Systems |volume=29 |issue=1 |pages=98–111 |doi=10.2478/acss-2024-0013}}</ref>
=={{anchor|Criticism}}Criticism==
Some believe that OOP places too much focus on using objects rather than on [[algorithm]]s and [[data structure]]s.<ref name="stepanov"/><ref name="hickey"/> For example, programmer [[Rob Pike]] pointed out that OOP can make programmers think more about type hierarchy than composition.<ref name="RobPike">{{cite web |url=https://commandcenter.blogspot.com/2012/06/less-is-exponentially-more.html |title=Less is exponentially more |last1=Pike |first1=Rob |date=25 June 2012 |access-date=1 October 2016}}</ref> He has called OOP "the [[Roman numerals]] of computing".<ref>{{cite mailing list |last1=Pike |first1=Rob |author1-link=Rob Pike |date=2 March 2004 |url=http://groups.google.com/group/comp.os.plan9/msg/006fec195aeeff15 |title=[9fans] Re: Threads: Sewing badges of honor onto a Kernel |access-date=17 November 2016 |mailing-list=comp.os.plan9}}</ref> [[Rich Hickey]], creator of [[Clojure]], described OOP as overly simplistic, especially when it comes to representing real-world things that change over time.<ref name="hickey">{{cite conference |last1=Hickey |first1=Rich |date=November 2009 |url=http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey |title=Are We There Yet? (keynote) |conference=JVM Languages Summit}}</ref> [[Alexander Stepanov]] said that OOP tries to fit everything into a single type, which can be limiting. He argued that sometimes we need multisorted algebras: families of interfaces that span multiple types, such as in [[generic programming]]. Stepanov also said that calling everything an "object" doesn't add much understanding.<ref name="stepanov">{{Cite web |last1=Stepanov |first1=Alexander |author1-link=Alexander Stepanov |year=2001–2008 |url=http://www.stlport.org/resources/StepanovUSA.html |title=STLport: An Interview with A. Stepanov |access-date=21 April 2010}}</ref>
OOP was created to make code easier to [[code reuse|reuse]] and [[software maintenance|maintain]].<ref name="realisticcodereuse">{{Cite web |last1=Ambler |first1=Scott |date=1 January 1998 |title=A Realistic Look at Object-Oriented Reuse |access-date=5 August 2025 |publisher=drdobbs.com |url=http://www.drdobbs.com/184415594}}</ref> However, it was not designed to clearly show the flow of a program's instructions. That was left to the compiler. As computers began using more parallel processing and multiple [[thread (computer science)|threads]], it became more important to understand and control how instructions flow. This is difficult to do with OOP.<ref name="flaws">{{Cite web |first1=Asaf |last1=Shelly |title=Flaws of Object Oriented Modeling |date=22 August 2008|access-date=4 July 2010 |publisher=Intel Software Network |url=http://software.intel.com/en-us/blogs/2008/08/22/flaws-of-object-oriented-modeling/}}</ref><ref name="multithreadingisaverb">{{Cite web |first1=Justin |last1=James |title=Multithreading is a verb not a noun |date=1 October 2007 |access-date=4 July 2010 |publisher=techrepublic.com |url=http://blogs.techrepublic.com.com/programming-and-development/?p=518 |archive-url=https://web.archive.org/web/20071010105117/http://blogs.techrepublic.com.com/programming-and-development/?p=518 |archive-date=10 October 2007 |url-status=dead |df=dmy-all}}</ref><ref name="multicore">{{Cite web |first1=Asaf |last1=Shelly |title=HOW TO: Multicore Programming (Multiprocessing) Visual C++ Class Design Guidelines, Member Functions |date=22 August 2008 |access-date=4 July 2010 |publisher=support.microsoft.com |url=http://support.microsoft.com/?scid=kb%3Ben-us%3B558117}}</ref><ref>{{cite web|url=http://existentialtype.wordpress.com/2011/04/17/some-advice-on-teaching-fp/|title=Some thoughts on teaching FP|author=Robert Harper |publisher=Existential Type Blog|access-date=5 December 2011|date=17 April 2011|author-link=Robert Harper (computer scientist)}}</ref>
Many popular programming languages, like C++, Java, and Python, use OOP. In the past, OOP was widely accepted,<ref>{{cite book |last1=Brucker |first1=Achim D. |last2=Wolff |first2=Burkhart |title=ECOOP 2008 – Object-Oriented Programming |chapter=Extensible Universes for Object-Oriented Data Models |series=Lecture Notes in Computer Science |date=2008 |volume=5142 |pages=438–462 |doi=10.1007/978-3-540-70592-5_19|isbn=978-3-540-70591-8 |quote=object-oriented programming is a widely accepted programming paradigm}}</ref> but recently, some programmers have criticized it and prefer functional programming instead.<ref>{{cite news |last1=Cassel |first1=David |title=Why Are So Many Developers Hating on Object-Oriented Programming? |url=https://thenewstack.io/why-are-so-many-developers-hating-on-object-oriented-programming/ |work=The New Stack |date=21 August 2019}}</ref> A study by Potok et al. found no major difference in productivity between OOP and other methods.<ref>{{Cite journal |url=http://www.csm.ornl.gov/~v8q/Homepage/Papers%20Old/spetep-%20printable.pdf |title=Productivity Analysis of Object-Oriented Software Developed in a Commercial Environment |last1=Potok |first1=Thomas |last2=Vouk |first2=Mladen |last3=Rindos |first3=Andy |journal=Software: Practice and Experience |volume=29|issue=10|pages=833–847 |year=1999 |access-date=21 April 2010 |doi=10.1002/(SICI)1097-024X(199908)29:10<833::AID-SPE258>3.0.CO;2-P |s2cid=57865731}}</ref>
[[Paul Graham (computer programmer)|Paul Graham]], a well-known computer scientist, believes big companies like OOP because it helps manage large teams of average programmers. He argues that OOP adds structure, making it harder for one person to make serious mistakes, but at the same time restrains smart programmers.<ref name="graham">{{Cite web |last1=Graham |first1=Paul |title=Why ARC isn't especially Object-Oriented. |url=http://www.paulgraham.com/noop.html |publisher=PaulGraham.com |access-date=13 November 2009 |author-link=Paul Graham (computer programmer)}}</ref> [[Eric S. Raymond]], a [[Unix]] programmer and [[open-source software]] advocate, argues that OOP is not the best way to write programs.<ref name="Eric S. Raymond 2003"/>
Richard Feldman says that, while OOP features helped some languages stay organized, their popularity comes from other reasons.<ref>{{cite web |last1=Feldman |first1=Richard |title=Why Isn't Functional Programming the Norm? |website=[[YouTube]] |date=30 September 2019 |url=https://www.youtube.com/watch?v=QyJZzq0v7Z4&t=2069s |language=en}}</ref> Lawrence Krubner argues that OOP doesn't offer special advantages compared to other styles, like functional programming, and can complicate coding.<ref name="lawrence">{{Cite web |last1=Krubner |first1=Lawrence |title=Object Oriented Programming is an expensive disaster which must end |url=http://www.smashcompany.com/technology/object-oriented-programming-is-an-expensive-disaster-which-must-end |publisher=smashcompany.com |access-date=14 October 2014 |archive-url=https://web.archive.org/web/20141014233854/http://www.smashcompany.com/technology/object-oriented-programming-is-an-expensive-disaster-which-must-end |archive-date=14 October 2014 |url-status=dead}}</ref> [[Luca Cardelli]] says that OOP is slower and takes longer to compile than procedural programming.<ref name="badprop">{{Cite journal |first1=Luca |last1=Cardelli|title=Bad Engineering Properties of Object-Oriented Languages |url=http://lucacardelli.name/Papers/BadPropertiesOfOO.html |year=1996 |access-date=21 April 2010 |doi=10.1145/242224.242415 |journal=ACM Comput. Surv. |volume=28 |issn=0360-0300 |pages=150–es |author-link=Luca Cardelli |issue=4es |s2cid=12105785 |url-access=subscription}}</ref>
==See also==
{{Portal|Computer programming}}
* [[CADES]]
* [[Common Object Request Broker Architecture]] (CORBA)
* [[Comparison of programming languages (object-oriented programming)]]
* [[Component-based software engineering]]
* [[Distributed Component Object Model]]
* [[Interface description language]]
* [[IDEF4]]
* [[Jeroo]]
* [[List of object-oriented programming languages]]
* [[Object association]]
* [[Object-oriented analysis and design]]
* [[Object-oriented modeling]]
* [[Object-oriented ontology]]
* [[UML]]
Line 350 ⟶ 296:
==Further reading==
* {{Cite book
|
|
|author-link=Martin Abadi
|author2=Luca Cardelli
Line 361 ⟶ 307:
}}
* {{Cite book
|
|
|author-link=Harold Abelson
|author2=Gerald Jay Sussman
Line 377 ⟶ 323:
}}
* {{Cite journal
|
|
|date=February 2006
|title
|journal
|volume
|issue
|pages
|issn
|doi
|s2cid
}}
*{{cite book
|
|
|
|
|
|
|
}}
* {{Cite book
|last1=Booch
|first1=Grady
|
|year=1997
|title=Object-Oriented Analysis and Design with Applications
Line 409 ⟶ 355:
}}
* {{Cite book
|
|
|author2=Oliver Sims
|year=1998
Line 420 ⟶ 366:
}}
* {{Cite book
|
|
|author-link=Erich Gamma
|author2=Richard Helm
Line 437 ⟶ 383:
}}
* {{Cite book
|
|
|author-link=Paul Harmon (management author)
|author2=William Morrissey
Line 448 ⟶ 394:
}}
* {{Cite book
|
|
|author-link=Ivar Jacobson
|year=1992
Line 459 ⟶ 405:
}}
* {{Cite book
|
|
|author-link
|title
|url
|access-date
|archive-url
|archive-date
|url-status
|df
}}
* {{Cite book
|
|
|author-link=Bertrand Meyer
|year=1997
Line 481 ⟶ 427:
}}
* {{Cite book
|
|
|year=2013
|title=OOP – Learn Object Oriented Thinking & Programming
Line 490 ⟶ 436:
}}
* {{Cite book
|last1=Rumbaugh
|first1=James
|
|last2=Blaha |first2=Michael
|
|last4=Eddy |first4=Frederick
|
|year=1991
|title=Object-Oriented Modeling and Design
Line 504 ⟶ 450:
}}
* {{Cite book
|
|
|year=2006
|title=Object-Oriented and Classical Software Engineering, Seventh Edition
Line 512 ⟶ 458:
}}
* {{Cite book
|
|
|year=1993
|title=Object oriented programming with ANSI-C
Line 520 ⟶ 466:
|hdl=1850/8544}}
* {{Cite book
|
|
|year=1992
|title=Object-Oriented Information Systems – Planning and Implementation
Line 529 ⟶ 475:
}}
* {{Cite book
|
|
|year=2009
|title=The Object-Oriented Thought Process, Third Edition
Line 537 ⟶ 483:
}}
* {{Cite book
|
|
|year=2004
|title=Object Thinking (Developer Reference)
Line 551 ⟶ 497:
* [http://www.codeproject.com/Articles/22769/Introduction-to-Object-Oriented-Programming-Concep Introduction to Object Oriented Programming Concepts (OOP) and More] by L.W.C. Nirosh
*[https://thenewstack.io/why-are-so-many-developers-hating-on-object-oriented-programming/ Discussion on Cons of OOP]
* [http://java.sun.com/docs/books/tutorial/java/concepts/
{{Programming paradigms navbox}}
{{Types of programming languages}}
{{Software engineering}}
{{Authority control}}
Line 561 ⟶ 507:
[[Category:Object-oriented programming| ]]
[[Category:Programming paradigms]]
<!-- Hidden categories below -->
[[Category:Articles with example code]]
|