Class-based programming: Difference between revisions

Content deleted Content added
m Establishing abbreviation.
Inheritance: better links, rewrite
Line 10:
 
==Inheritance==
:''See [[{{main|Inheritance (object-oriented programming)|l1=Inheritance]]''}}
 
In class-based programming, [[inheritance (object-oriented programming)|inheritance]] is done by defining new classes as [[Extension (semantics)|extensions]] of existing classes: the existing class is the [[parent class]] and the new class is the [[child class]]. If a child class has only one parent class, this is known as ''[[single inheritance]],'' while if a child class can have more than one parent class, this is known as ''[[multiple inheritance]].'' This organizes classes into a [[hierarchy]], either a ''[[Tree (set theory)|tree]]'' (if single inheritance) or ''[[Lattice (order)|lattice]]'' (if multiple inheritance).
[[Inheritance (computer science)|Inheritance]] is typically done by grouping objects into ''classes'', and defining [[class (computer science)|class]]es as [[Extension (semantics)|extension]]s of existing classes, and thus grouping classes into ''trees'' or ''lattices'' reflecting behavioral commonality. Although the use of classes is the most popular technique for inheritance, another well-known technique is prototype-based programming.
 
The defining feature of inheritance is that both interface and implementation are inherited; if only interface is inherited, this is known as [[interface inheritance]] or ''subtyping.'' Inheritance can also be done without classes, as in [[prototype-based programming]].
 
==Critique of class-based models==