Composition over inheritance: Difference between revisions

Content deleted Content added
Drawbacks: rm bare URLs template – already at the top of the seller
Tags: Mobile edit Mobile web edit Advanced mobile edit
Removed Python because the stackoverflow answers references are bullshit. One is an awful hack at best. The other is only for a single internal class, not for more than one. Python has no mitigation for the problem stated. OTOH it has no problem with diamond inheritance.
Line 291:
* [[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 __getattr__ magic method to forward<ref>https://stackoverflow.com/a/69444626/15354395</ref> 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}} trait 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.