Content deleted Content added
Polyamorph (talk | contribs) m Reverted edits by 37.76.26.253 (talk) to last version by Polyamorph |
Jerryobject (talk | contribs) Small WP:EoS WP:COPYEDITs: clarify. WP:LINKs update. |
||
Line 2:
{{Programming paradigms}}
'''Class-based programming''', or more commonly '''class-orientation''', is a style of [[
The most popular and developed model of OOP is a class-based model,
{{Quote box
|quote
|author = Junade Ali
|source = ''Mastering PHP Design Patterns''<ref>{{cite book|last1=Ali|first1=Junade|title=Mastering PHP Design Patterns {{!}} PACKT Books|date=|publisher=Packt Publishing Limited|___location=Birmingham, England, UK|isbn=978-1-78588-713-0|page=11|edition=1|url=https://www.packtpub.com/application-development/mastering-php-design-patterns|accessdate=11 December 2017|language=en}}</ref>
|width
|align
}}
Line 33:
:''Let {{math| '''q(x)''' }} be a property provable about objects {{math| '''x''' }} of type {{math| '''T'''. }} Then {{math| '''q(y)''' }} should be provable for objects {{math| '''y''' }} of type {{math| '''S''', }} where {{math| '''S''' }} is a subtype of {{math| '''T'''. }}''
-->
Also, another common example is that a person object created from a [[Subclass (computer science)|child class]] cannot become an object of [[parent class]] because a child class and a parent class inherit a person class but class-based languages mostly do not allow to change the kind of class of the object at runtime. For class-based languages, this restriction is essential in order to preserve unified view of the class to its users. The users should not need to care whether one of the implementations of a method happens to cause changes that break the [[Invariant (computer science)|invariants]] of the class. Such changes can be made by destroying the object and constructing another in its place. Polymorphism can be used to preserve the relevant interfaces even when such changes are done, because the objects are viewed as black box abstractions and accessed via object [[identity (object-oriented programming)|identity]]. However, usually the value of object references referring to the object is changed, which causes effects to client code.
|