Composition over inheritance: Difference between revisions

Content deleted Content added
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.
Avoiding drawbacks: Ref for PHP
Line 290:
* [[Julia (programming language)|Julia]] macros can be used to generate forwarding methods. Several implementations exist such as Lazy.jl<ref>https://github.com/MikeInnes/Lazy.jl</ref> and TypedDelegation.jl.<ref>https://github.com/JeffreySarnoff/TypedDelegation.jl</ref><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]], since PHP 5.4.<ref>{{cite web |title=PHP: Traits |url=https://www.php.net/manual/en/language.oop5.traits.php |website=www.php.net |access-date=23 February 2023}}</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.