<P> Some languages, notably Go, use type composition exclusively . </P> <P> One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be implemented in the derived type, even if they are only forwarding methods . In contrast, inheritance does not require all of the base class's methods to be re-implemented within the derived class . Rather, the derived class only needs to implement (override) the methods having different behavior than the base class methods . This can require significantly less programming effort if the base class contains many methods providing default behavior and only a few of them need to be overridden within the derived class . </P> <P> For example, in the code below, the variables and methods of the Employee base class are inherited by the HourlyEmployee and SalariedEmployee derived subclasses . Only the 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 . </P> <P> This drawback can be avoided by using traits, mixins, or protocol extensions . Some languages, such as Perl 6, provide a handles keyword to facilitate method forwarding . In Java, Project Lombok lets you implement delegation using a single @ Delegate annotation on the field instead of copying and maintaining names and types of all methods from the delegated field . In Swift, extensions can be used to define a default implementation of a protocol on the protocol itself, rather than within an individual type's implementation . In @ Kotlin the delegation pattern has been included into the language syntax . </P>

When do you favour abstract class over interface