Object-oriented programming: Difference between revisions

Content deleted Content added
Reverting edit(s) by 172.59.120.127 (talk) to rev. 1256782476 by Jarble: Non-constructive edit (UV 0.1.6)
Inheritance: Small WP:COPYEDIT WP:EoS WP:TERSE: cut needless words repeat. WP:LINKs: update-standardize, add.
Line 145:
 
===Inheritance===
OOP languages are diverse, but typically OOP languages allow [[Inheritance (object-oriented programming)|inheritance]] for code reuse and extensibility in the form of either [[classClass (computer scienceprogramming)|classes]] or [[Prototype-based programming|prototypes]]. These forms of inheritance are significantly different, but analogous terminology is used to define the concepts of ''object'' and ''instance''.
 
==== Class-based ====
Line 167:
==== Absence ====
 
Some languages like [[Go (programming language)|Go]] do not support inheritance at all. Go states that it is object-oriented,<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> and 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> 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. [[Delegation (object-oriented programming)|Delegation]] is another language feature that can be used as an alternative to inheritance.
 
[[Rob Pike]] has criticized the OO mindset for preferring a multilevel type hierarchy with layered abstractions to a three-line [[lookup table]].<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> He has called object-oriented programming "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 |date=2 March 2004 |access-date=17 November 2016 |mailing-list=comp.os.plan9 |last=Pike |first=Rob |author-link=Rob Pike}}</ref>
 
[[Robert C. Martin|Bob Martin]] states that because they are software, related classes do not necessarily share the relationships of the things 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>
 
===Dynamic dispatch/message passing===