Composition over inheritance: Difference between revisions

Content deleted Content added
Line 287:
* [[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> supports delegation using the {{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>
* [[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].<ref>{{cite web |title=Method forwarding macro |url=https://discourse.julialang.org/t/method-forwarding-macro/23355 |website=JuliaLang |access-date=18 August 2022 |language=en |date=20 April 2019}}</ref>
* [[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>
* [[PHP]] supports [[Traits (computer science)|traits]].
* [[Python (programming language)|Python]] supports use of the [https://stackoverflow.com/a/69444626/15354395 __getattr__ magic method to forward] attribute requests.<ref>{{Cite web |title=Best way to forward/redirect methods/attributes in python class without redundant code/docstrings? |url=https://stackoverflow.com/questions/69444593/best-way-to-forward-redirect-methods-attributes-in-python-class-without-redundan |access-date=2022-04-26 |website=Stack Overflow |language=en}}</ref>
* [[Raku (programming language)|Raku]] provides a {{code|handles}} keywordtrait to facilitate method forwarding.<ref>{{cite web |title=Type system |url=https://docs.raku.org/language/typesystem#index-entry-handles_trait-handles |website=docs.raku.org |access-date=18 August 2022}}</ref>
* [[Rust (programming language)|Rust]] provides traits with default implementations.
* [[Scala (programming language)|Scala]] (since version 3) provides an "export" clause to define aliases for selected members of an object.<ref>{{cite web | url=https://docs.scala-lang.org/scala3/reference/other-new-features/export.html | title=Export Clauses | website=Scala Documentation | access-date=2021-10-06}}</ref>