Object-oriented programming: Difference between revisions

Content deleted Content added
move UML diagram down to features, it still has too many floats at the top but it's better
Yamin8000 (talk | contribs)
m fixed some spellings
Line 62:
}}
 
Influenced by the work at MIT and the Simula language, in November 1966 [[Alan Kay]] began working on ideas that would eventually be incorporated into the [[Smalltalk]] programming language. Kay used the term "object-oriented programming" in conversation as early as 1967.<ref name=alanKayOnOO/> Although sometimes called "the father of object-oriented programming",<ref>{{cite book |last1=Butcher |first1=Paul |title=Seven Concurrency Models in Seven Weeks: When Threads Unravel |date=30 June 2014 |publisher=Pragmatic Bookshelf |isbn=978-1-68050-466-8 |page=204 |url=https://books.google.com/books?id=Xg9QDwAAQBAJ&pg=PT204 |language=en}}</ref> Alan Kay has differentiated his notion of OO from the more conventional [[abstract data type]] notion of object, and has implied that the computer science establishment did not adopt his notion.<ref name=alanKayOnOO>{{Cite web|url= http://www.purl.org/stefan_ram/pub/doc_kay_oop_en |title=Dr. Alan Kay on the Meaning of "Object-Oriented Programming" |year= 2003|access-date=11 February 2010}}</ref> 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 |last=Jones |first=Anita K. |last2=Liskov|first2=Barbara H. |date=April 1976 |title=An Access Control Facility for Programming Languages |institution=MIT |number=CSG Memo 137|url=http://csg.csail.mit.edu/CSGArchives/memos/Memo-137.pdf }}</ref>
 
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 included a programming environment and was [[Dynamic programming|dynamically typed]], and at first was [[Interpreter (computing)|interpreted]], not [[Compiler|compiled]]. Smalltalk became noted for its application of object orientation at the language-level and its graphical development environment. Smalltalk went through various versions and interest in the language grew.<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> While [[Smalltalk]] was influenced by the ideas introduced in Simula 67 it was designed to be a fully dynamic system in which classes could be created and modified dynamically.<ref name="st">{{Cite web|first=Alan |last=Kay |url=http://gagne.homedns.org/~tgagne/contrib/EarlyHistoryST.html |title=The Early History of Smalltalk |access-date=13 September 2007 |url-status=dead |archive-url=https://web.archive.org/web/20080710144930/http://gagne.homedns.org/~tgagne/contrib/EarlyHistoryST.html |archive-date=10 July 2008 }}</ref>
 
During the late 1970s and 1980s, object-oriented programming rose to prominence. The [[Flavors (programming language)|Flavors]] object-oriented Lisp was developed starting 1979, introducing [[multiple inheritance]] and [[mixins]].<ref>{{cite conference |last1=Moon |first1=David A. |author-link1=David A. Moon |date=June 1986 |title=Object-Oriented Programming with Flavors |book-title=Conference proceedings on Object-oriented Programming Systems Languages and Applications |pages=1–8 |isbn=978-0-89791-204-4 |conference=[[OOPSLA]] '86 |doi=10.1145/28697.28698 |s2cid=17150741 |url=https://www.cs.tufts.edu/comp/150FP/archive/david-moon/flavors.pdf |access-date=2022-03-17}}</ref> In 1981, Goldberg edited the August issue of [[Byte Magazine]], introducing Smalltalk and object-oriented programming to a wide audience.<ref>{{cite news |title=Introducing the Smalltalk Zoo |url=https://computerhistory.org/blog/introducing-the-smalltalk-zoo-48-years-of-smalltalk-history-at-chm/ |work=CHM |date=17 December 2020 |language=en}}</ref> LOOPS, the object system for [[Interlisp]]-D, was influenced by Smalltalk and Flavors, and a paper about it was published in 1982.<ref>{{cite conference | title=LOOPS: data and object oriented Programming for Interlisp|date=1982|conference=European AI Conference|last1=Bobrow|first1=D. G.|last2=Stefik|first2=M. J|url=https://www.markstefik.com/wp-content/uploads/2011/04/1982-Bobrow-Stefik-Data-Object-Pgming.pdf}}</ref> In 1986, the [[Association for Computing Machinery]] organisedorganized the first ''Conference on Object-Oriented Programming, Systems, Languages, and Applications'' (OOPSLA), which was attended by 1,000 people. Among other developments was the [[Common Lisp Object System]], which integrates functional programming and object-oriented programming and allows extension via a [[Meta-object protocol]]. In the 1980s, there were a few attempts to design processor architectures that included hardware support for objects in memory but these were not successful. Examples include the [[Intel iAPX 432]] and the [[Linn Products|Linn Smart]] [[Rekursiv]].
 
In the mid-1980s [[Objective-C]] was developed by [[Brad Cox]], who had used Smalltalk at [[ITT Inc.]]. [[Bjarne Stroustrup]], who had used Simula for his PhD thesis, created the object-oriented [[C++]].<ref name="Bertrand Meyer 2009 329"/> In 1985, [[Bertrand Meyer]] also produced the first design of the [[Eiffel (programming language)|Eiffel language]]. Focused on software quality, Eiffel is a purely object-oriented programming language and a notation supporting the entire software lifecycle. Meyer described the Eiffel software development method, based on a small number of key ideas from software engineering and computer science, in [[Object-Oriented Software Construction]]. Essential to the quality focus of Eiffel is Meyer's reliability mechanism, [[Design by Contract]], which is an integral part of both the method and language.
Line 73:
In the early and mid-1990s object-oriented programming developed as the dominant programming [[paradigm]] when programming languages supporting the techniques became widely available. These included Visual [[FoxPro]] 3.0,<ref>1995 (June) Visual [[FoxPro]] 3.0, FoxPro evolves from a procedural language to an object-oriented language. Visual FoxPro 3.0 introduces a database container, seamless client/server capabilities, support for ActiveX technologies, and OLE Automation and null support. [http://www.foxprohistory.org/foxprotimeline.htm#summary_of_fox_releases Summary of Fox releases]</ref><ref>FoxPro History web site: [http://www.foxprohistory.org/tableofcontents.htm Foxprohistory.org]</ref><ref>1995 Reviewers Guide to Visual FoxPro 3.0: [http://www.dfpug.de/loseblattsammlung/migration/whitepapers/vfp_rg.htm DFpug.de]</ref> [[C++]],<ref>{{Cite book|url=https://books.google.com/books?id=MHmqfSBTXsAC&pg=PA16|title=Object Oriented Programming with C++, 1E|isbn=978-81-259-2532-3|last1=Khurana|first1=Rohit|date=1 November 2009|publisher=Vikas Publishing House Pvt Limited }}</ref> and [[Delphi (programming language)|Delphi]]{{Citation needed|date=February 2010}}. Its dominance was further enhanced by the rising popularity of [[graphical user interface]]s, which rely heavily upon object-oriented programming techniques. An example of a closely related dynamic GUI library and OOP language can be found in the [[Cocoa (software)|Cocoa]] frameworks on [[Mac OS X]], written in [[Objective-C]], an object-oriented, dynamic messaging extension to C based on Smalltalk. OOP toolkits also enhanced the popularity of [[event-driven programming]] (although this concept is not limited to OOP).
 
At [[ETH Zürich]], [[Niklaus Wirth]] and his colleagues investigated the concept of type checking across module boundaries. [[Modula-2]] (1978) included this concept, and their succeeding design, [[Oberon (programming language)|Oberon]], included a distinctive approach to object orientation, classes, and such. 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.
 
Object-oriented features have been added to many previously existing languages, including [[Ada (programming language)|Ada]], [[BASIC]], [[Fortran]], [[Pascal (programming language)|Pascal]], and [[COBOL]]. Adding these features to languages that were not initially designed for them often led to problems with compatibility and maintainability of code.
 
More recently, a number ofsome languages have emerged that are primarily object-oriented, but that are also compatible with procedural methodology. Two such languages are [[Python (programming language)|Python]] and [[Ruby programming language|Ruby]]. Probably the most commercially important recent object-oriented languages are [[Java (programming language)|Java]], developed by [[Sun Microsystems]], as well as [[C Sharp (programming language)|C#]] and [[Visual Basic.NET]] (VB.NET), both designed for Microsoft's [[.NET Framework|.NET]] platform. Each of these two frameworks shows, in its own way, the benefit of using OOP by creating an abstraction from implementation. VB.NET and C# support cross-language inheritance, allowing classes defined in one language to subclass classes defined in the other language.
 
==Features==
[[File:oop-uml-class-example.png|frame|right|[[Unified Modeling Language|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.]]
{{See also|Comparison of programming languages (object-oriented programming)|List of object-oriented programming terms}}
Object-oriented programming uses objects, but not all of the associated techniques and structures are supported directly in languages that claim to support OOP. It performs operations on operands. The features listed below are common among languages considered to be strongly class- and object-oriented (or [[multi-paradigm]] with OOP support), with notable exceptions mentioned.<ref name="ArmstrongQuarks">Deborah J. Armstrong. ''The Quarks of Object-Oriented Development''. A survey of nearly 40 years of computing literature which identified a number ofseveral 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>
 
===Shared with non-OOP languages===
Line 95:
* [[Object (computer science)|Objects]] – instances of classes
 
Objects sometimes correspond to things found in the real world. For example, a graphics program may have objects such as "circle", "square", and "menu". An online shopping system might have objects such as "shopping cart", "customer", and "product".<ref>{{cite book|last=Booch|first=Grady|title=Software Engineering with Ada|year=1986|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> Sometimes objects represent more abstract entities, like an object that represents an open file, or an object that provides the service of translating measurements from U.S. customary to metric.
 
Each object is said to be an [[instance (computer science)|instance]] of a particular class (for example, an object with its name field set to "Mary" might be an instance of class Employee). Procedures in object-oriented programming are known as [[Method (computer science)|methods]]; variables are also known as [[Field (computer science)|fields]], members, attributes, or properties. This leads to the following terms:
Line 104:
* Instance methods – belong to ''individual objects'', and have access to instance variables for the specific object they are called on, inputs, and class variables
 
Objects are accessed somewhat like variables with complex internal structurestructures, and in many languages are effectively [[Pointer (computer programming)|pointers]], serving as actual references to a single instance of said object in memory within a heap or stack. They provide a layer of [[Abstraction (computer science)|abstraction]] which can be used to separate internal from external code. External code can use an object by calling a specific instance method with a certain set of input parameters, readreading an instance variable, or writewriting to an instance variable. Objects are created by calling a special type of method in the class known as a [[Constructor (object-oriented programming)|constructor]]. A program may create many instances of the same class as it runs, which operate independently. This is an easy way for the same procedures to be used on different sets of data.
 
Object-oriented programming that uses classes is sometimes called [[class-based programming]], while [[prototype-based programming]] does not typically use classes. As a result, significantly different yet analogous terminology is used to define the concepts of ''object'' and ''instance''.
Line 113:
In [[Class-based programming|class-based languages]] the ''classes'' are defined beforehand and the ''objects'' are instantiated based on the classes. If two objects ''apple'' and ''orange'' are instantiated from the class ''Fruit'', they are inherently fruits and it is guaranteed that you may handle them in the same way; e.g. a programmer can expect the existence of the same attributes such as ''color'' or ''sugar_content'' or ''is_ripe''.
 
In [[Prototype-based programming|prototype-based languages]] the ''objects'' are the primary entities. No ''classes'' even exist. The ''prototype'' of an object is just another object to which the object is linked. Every object has one ''prototype'' link (and only one). New objects can be created based on already existing objects chosen as their prototype. You may call two different objects ''apple'' and ''orange'' a fruit, if the object ''fruit'' exists, and both ''apple'' and ''orange'' have ''fruit'' as their prototype. The idea of the ''fruit'' class does not exist explicitly, but as the [[equivalence class]] of the objects sharing the same prototype. The attributes and methods of the ''prototype'' are [[Delegation (object-oriented programming)|delegated]] to all the objects of the equivalence class defined by this prototype. The attributes and methods ''owned'' individually by the object may not be shared by other objects of the same equivalence class; e.g. the attribute ''sugar_content'' may be unexpectedly not present in ''apple''. Only [[single inheritance]] can be implemented through the prototype.
 
===Dynamic dispatch/message passing===
Line 121:
 
===Data abstraction===
Data abstraction is a design pattern in which data are visible only to semantically related functions, so as to prevent misuse. The success of data abstraction leads to frequent incorporation of [[Information hiding|data hiding]] as a design principle in object -oriented and pure functional programming.
 
If a class does not allow calling code to access internal object data and permits access through methods only, this is a form of information hiding known as [[Abstraction (computer science)|abstraction]]. Some languages (Java, for example) let classes enforce access restrictions explicitly, for example, denoting internal data with the <code>private</code> keyword and designating methods intended for use by code outside the class with the <code>public</code> keyword.{{sfn|Bloch|2018|loc=Chapter §4 Item15 Minimize the accessibility of classes and members|pp=73-77}} Methods may also be designed public, private, or intermediate levels such as <code>protected</code> (which allows access from the same class and its subclasses, but not objects of a different class).{{sfn|Bloch|2018|loc=Chapter §4 Item15 Minimize the accessibility of classes and members|pp=73-77}} In other languages (like Python) this is enforced only by convention (for example, <code>private</code> methods may have names that start with an [[underscore]]). In C#, Swift & Kotlin languages, <code>internal</code> keyword permits access only to files present in the same assembly, package, or module as that of the class.<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}}</ref>
 
In programming languages, particularly object-oriented ones, the emphasis on abstraction is vital. Object-oriented languages extend the notion of type to incorporate data abstraction, highlighting the significance of restricting access to internal data through methods.<ref>{{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>
Line 132:
 
===Composition, inheritance, and delegation===
Objects can contain other objects in their instance variables; this is known as [[object composition]]. For example, an object in the Employee class might contain (either directly or through a pointer) an object in the Address class, in addition to its own instance variables like "first_name" and "position". Object composition is used to represent "has-a" relationships: every employee has an address, so every Employee object has access to a place to store an Address object (either directly embedded within itself, or at a separate ___location addressed via a pointer).
 
Languages that support classes almost always support [[inheritance (object-oriented programming)|inheritance]]. This allows classes to be arranged in a hierarchy that represents "is-a-type-of" relationships. For example, class Employee might inherit from class Person. All the data and methods available to the parent class also appear in the child class with the same names. For example, class Person might define variables "first_name" and "last_name" with method "make_full_name()". These will also be available in class Employee, which might add the variables "position" and "salary". This technique allows easy re-use of the same procedures and data definitions, in addition to potentially mirroring real-world relationships in an intuitive wayintuitively. Rather than utilizing database tables and programming subroutines, the developer utilizes objects the user may be more familiar with: objects from their application ___domain.<ref>{{cite book|last=Jacobsen|first=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>
 
Subclasses can override the methods defined by superclasses. [[Multiple inheritance]] is allowed in some languages, though this can make resolving overrides complicated. Some languages have special support for [[mixin]]s, though, in any language with multiple inheritance, a mixin is simply a class that does not represent an is-a-type-of relationship. Mixins are typically used to add the same methods to multiple classes. For example, class UnicodeConversionMixin might provide a method unicode_to_ascii() when included in class FileReader and class WebPageScraper, which do not share a common parent.
 
[[Abstract class]]es cannot be instantiated into objects; they exist only for the purpose of inheritance into other "concrete" classes that can be instantiated. In Java, the <code>[[final (Java)|final]]</code> keyword can be used to prevent a class from being subclassed.{{sfn|Bloch|2018|loc=Chapter §2 Item 4 Enforce noninstantiability with a private constructor|p=19}}
 
The doctrine of [[composition over inheritance]] advocates implementing has-a relationships using composition instead of inheritance. For example, instead of inheriting from class Person, class Employee could give each Employee object an internal Person object, which it then has the opportunity to hide from external code even if class Person has many public attributes or methods. Some languages, like [[Go (programming language)|Go]] do not support inheritance at all.
Line 149:
[[Subtyping]] – a form of [[polymorphism (computer science)|polymorphism]] – is when calling code can be independent of which class in the supported hierarchy it is operating on – the parent class or one of its descendants. Meanwhile, the same operation name among objects in an inheritance hierarchy may behave differently.
 
For example, objects of the type Circle and Square are derived from a common class called Shape. The Draw function for each type of Shape implements what is necessary to draw itself while calling code can remain indifferent to the particular type of Shape being drawn.
 
This is another type of abstraction that simplifies code external to the class hierarchy and enables strong [[separation of concerns]].
Line 160:
{{See also|List of object-oriented programming languages}}
 
[[Simula]] (1967) is generally accepted as being the first language with the primary features of an object-oriented language. It was created for making [[Computer simulation|simulation programs]], in which what came to be called objects were the most important information representation. [[Smalltalk]] (1972 to 1980) is another early example, and the one with which much of the theory of OOP was developed. Concerning the degree of object orientation, the following distinctions can be made:
<!-- Order lists of examples based on [[TIOBE index]]-->
* Languages called "pure" OO languages, because everything in them is treated consistently as an object, from primitives such as characters and punctuation, all the way up to whole classes, prototypes, blocks, modules, etc. They were designed specifically to facilitate, even enforce, OO methods. Examples: [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Smalltalk]], [[Eiffel (programming language)|Eiffel]], [[Emerald (programming language)|Emerald]],<ref>{{cite web|url=http://www.emeraldprogramminglanguage.org/|title=The Emerald Programming Language| date=26 February 2011}}</ref> [[JADE (programming language)|JADE]], [[Self (programming language)|Self]], [[Raku (programming language)|Raku]].
Line 175:
 
===OOP in a network protocol===
The messages that flow between computers to request services in a client-server environment can be designed as the linearizations of objects defined by class objects known to both the client and the server. For example, a simple linearized object would consist of a length field, a code point identifying the class, and a data value. A more complex example would be a command consisting of the length and code point of the command and values consisting of linearized objects representing the command's parameters. Each such command must be directed by the server to an object whose class (or superclass) recognizes the command and is able tocan provide the requested service. Clients and servers are best modeled as complex object-oriented structures. [[Distributed Data Management Architecture]] (DDM) took this approach and used class objects to define objects at four levels of a formal hierarchy:
* Fields defining the data values that form messages, such as their length, code point and data values.
* Objects and collections of objects similar to what would be found in a [[Smalltalk]] program for messages and parameters.
* Managers similar to [[IBM i]] [[Object (IBM i)|Object]]s, such as a directory to files and files consisting of metadata and records. Managers conceptually provide memory and processing resources for their contained objects.
* A client or server consisting of all the managers necessary to implement a full processing environment, supporting such aspects as directory services, security, and concurrency control.
 
The initial version of DDM defined distributed file services. It was later extended to be the foundation of [[DRDA|Distributed Relational Database Architecture]] (DRDA).
 
==Design patterns==
Challenges of object-oriented design are addressed by several approaches. MostThe most common is known as the [[Design Patterns (book)|design patterns codified by Gamma ''et al.'']]. More broadly, the term "[[design pattern (computer science)|design patterns]]" can be used to refer to any general, repeatable, solution pattern to a commonly occurring problem in software design. Some of these commonly occurring problems have implications and solutions particular to object-oriented development.
 
===Inheritance and behavioral subtyping===
Line 201:
===Object-orientation and databases===
{{Main|Object-relational impedance mismatch|Object-relational mapping|Object database}}
Both object-oriented programming and [[relational database management systems]] (RDBMSs) are extremely common in software {{As of|2006|alt=today}}. Since [[relational database]]s do not store objects directly (though some RDBMSs have object-oriented features to approximate this), there is a general need to bridge the two worlds. The problem of bridging object-oriented programming accesses and data patterns with relational databases is known as [[object-relational impedance mismatch]]. There are a number ofsome approaches to cope with this problem, but no general solution without downsides.<ref name="RDMDBobjectmis">{{Cite web| first = Ted| last = Neward| title = The Vietnam of Computer Science| date = 26 June 2006| access-date = 2 June 2010| publisher = Interoperability Happens| url = http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx| archive-url = https://web.archive.org/web/20060704030226/http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx| archive-date = 4 July 2006| url-status = dead| df = dmy-all}}</ref> One of the most common approaches is [[object-relational mapping]], as found in [[Integrated development environment|IDE]] languages such as [[Visual FoxPro]] and libraries such as [[Java Data Objects]] and [[Ruby on Rails]]' ActiveRecord.
 
There are also [[object database]]s that can be used to replace RDBMSs, but these have not been as technically and commercially successful as RDBMSs.
Line 209:
For example, the [[circle-ellipse problem]] is difficult to handle using OOP's concept of [[inheritance (object-oriented programming)|inheritance]].
 
However, [[Niklaus Wirth]] (who popularized the adage now known as [[Wirth's law]]: "Software is getting slower more rapidly than hardware becomes faster") said of OOP in his paper, "Good Ideas through the Looking Glass", "This paradigm closely reflects the structure of systems 'in the real world', and it is therefore well suited to model complex systems with complex behavioursbehaviors"<ref>{{cite journal |title=Good Ideas, Through the Looking Glass |journal=[[Computer (magazine)|Computer]] |year=2006 |last=Wirth |first=Niklaus |author-link=Niklaus Wirth |volume=39 |issue=1 |pages=28–39 |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 |access-date=2 October 2016 |doi=10.1109/mc.2006.20|s2cid=6582369 }}</ref> (contrast [[KISS principle]]).
 
[[Steve Yegge]] and others noted that natural languages lack the OOP approach of strictly prioritizing ''things'' (objects/[[noun]]s) before ''actions'' (methods/[[verb]]s).<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 problem may cause OOP to suffer more convoluted solutions than 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>
Line 230:
 
==Criticism==
The OOP paradigm has been criticisedcriticized for a number ofseveral reasons, including not meeting its stated goals of reusability and modularity,<ref name="badprop"/><ref name="armstrongjoe"/> and for overemphasizing one aspect of software design and modeling (data/objects) at the expense of other important aspects (computation/algorithms).<ref name="stepanov"/><ref name="hickey"/>
 
[[Luca Cardelli]] has claimed that OOP code is "intrinsically less efficient" than procedural code, that OOP can take longer to compile, and that OOP languages have "extremely poor modularity properties with respect to class extension and modification", and tend to be extremely complex.<ref name="badprop">{{Cite journal| first=Luca| last=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}}</ref> The latter point is reiterated by [[Joe Armstrong (programming)|Joe Armstrong]], the principal inventor of [[Erlang (programming language)|Erlang]], who is quoted as saying:<ref name="armstrongjoe">Armstrong, Joe. In ''Coders at Work: Reflections on the Craft of Programming.'' Peter Seibel, ed. [http://www.codersatwork.com/ Codersatwork.com] {{Webarchive|url=https://web.archive.org/web/20100305165150/http://www.codersatwork.com/ |date=5 March 2010 }}, Accessed 13 November 2009.</ref>
Line 240:
[[Christopher J. Date]] stated that critical comparison of OOP to other technologies, relational in particular, is difficult because of lack of an agreed-upon and rigorous definition of OOP;<ref name="DatePage650">C. J. Date, Introduction to Database Systems, 6th-ed., Page 650</ref> however, Date and Darwen have proposed a theoretical foundation on OOP that uses OOP as a kind of customizable [[data type|type system]] to support [[RDBMS]].<ref name="ThirdManifesto">C. J. Date, Hugh Darwen. ''Foundation for Future Database Systems: The Third Manifesto'' (2nd Edition)</ref>
 
In an article, Lawrence Krubner claimed that compared to other languages (LISP dialects, functional languages, etc.) OOP languages have no unique strengths, and inflict a heavy burden of unneeded complexity.<ref name="lawrence">{{Cite web| last=Krubner| first=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>
 
[[Alexander Stepanov]] compares object orientation unfavourably to [[generic programming]]:<ref name="stepanov">{{Cite web| url=http://www.stlport.org/resources/StepanovUSA.html| title=STLport: An Interview with A. Stepanov| last=Stepanov| first=Alexander| access-date=21 April 2010| author-link=Alexander Stepanov}}</ref>
Line 271:
* encapsulated state
* [[Inheritance (object-oriented programming)|inheritance]]
* [[Record (computer science)|records]] are the basis for understanding objects if [[function literal]]s can be stored in fields (like in functional-programming languages), but the actual calculi need be considerably more complex to incorporate essential features of OOP. Several extensions of [[System F-sub|System F<sub><:</sub>]] that deal with mutable objects have been studied;<ref name="AbadiCardelli"/> these allow both [[subtype polymorphism]] and [[parametric polymorphism]] (generics)
 
Attempts to find a consensus definition or theory behind objects have not proven very successful (however, see Abadi & Cardelli, [http://portal.acm.org/citation.cfm?id=547964&dl=ACM&coll=portal ''A Theory of Objects'']<ref name="AbadiCardelli">{{Cite book| first=Martin| last=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> for formal definitions of many OOP concepts and constructs), and often diverge widely. For example, some definitions focus on mental activities, and some on program structuring. One of the simpler definitions is that OOP is the act of using "map" data structures or arrays that can contain functions and pointers to other maps, all with some [[syntactic sugar|syntactic and scoping sugar]] on top. Inheritance can be performed by cloning the maps (sometimes called "prototyping").