Composition over inheritance: Difference between revisions

Content deleted Content added
Cth027 (talk | contribs)
m See also: object composition
No edit summary
Line 286:
* [[Dart (programming language)|Dart]] provides mixins with default implementations that can be shared.
* [[Go (programming language)|Go]] type embedding avoids the need for forwarding methods.<ref>{{cite web | url=https://golang.org/doc/effective_go.html#embedding | title=''(Type)'' Embedding | website=The Go Programming Language Documentation | access-date=2019-05-10}}</ref>
* [[Java (programming language)|Java]] provides default interface methods since version 8. Project Lombok<ref>https://projectlombok.org</ref> which allowssupports delegation to be implemented using a singlethe {{code|@Delegate}} annotation on the field, instead of copying and maintaining the names and types of all the methods from the delegated field.<ref>{{cite web | url=https://projectlombok.org/features/Delegate.html | title=@Delegate | website=Project Lombok | access-date=2018-07-11}}</ref> Java 8 allows for default methods in an interface, similar to C# etc.
* [[Julia (programming language)|Julia]] macros can be used to generate forwarding methods. Several implementations exist such as [https://github.com/MikeInnes/Lazy.jl Lazy.jl] and [https://github.com/JeffreySarnoff/TypedDelegation.jl TypedDelegation.jl].
* [[Kotlin (programming language)|Kotlin]] includes the delegation pattern in the language syntax.<ref>{{cite web | url=https://kotlinlang.org/docs/reference/delegated-properties.html | title=Delegated Properties | website=Kotlin Reference | publisher=JetBrains | access-date=2018-07-11}}</ref>