Composition over inheritance: Difference between revisions

Content deleted Content added
top: remove old 'confusing' tag; maybe simplified but it'll always remain confusing to someone
Drawbacks: add UML image
Line 238:
 
For example, in the C# code below, the variables and methods of the {{code|Employee}} base class are inherited by the {{code|HourlyEmployee}} and {{code|SalariedEmployee}} derived subclasses. Only the {{code|Pay()}} method needs to be implemented (specialized) by each derived subclass. The other methods are implemented by the base class itself, and are shared by all of its derived subclasses; they do not need to be re-implemented (overridden) or even mentioned in the subclass definitions.
 
[[File:UML class Employee.svg|UML class Employee.svg]]
 
<syntaxhighlight lang="csharp">