rust-lang / book

The Rust Programming Language
https://doc.rust-lang.org/book/
Other
14.87k stars 3.36k forks source link

Chapter on "composition" aka "How to (not) do OOP in Rust" #109

Closed azerupi closed 7 years ago

azerupi commented 8 years ago

A lot of people coming from OOP languages have a hard time unlearning inheritance and thinking in terms of composition. I think it would be interesting to have a chapter explaining the difference between both and give some examples of how you might use composition instead of inheritance.

carols10cents commented 7 years ago

Related:

carols10cents commented 7 years ago

I'm going to close this issue since we now have a placeholder for the proposed chapter here as Chapter 15 (we haven't started writing it yet though). ❤️

carols10cents commented 7 years ago

https://www.reddit.com/r/rust/comments/5awfhn/help_replacing_old_programming_patterns/

carols10cents commented 7 years ago

https://www.reddit.com/r/programming/comments/5dxq6i/composition_over_inheritance/?st=ivsajq23&sh=30cc5af6

carols10cents commented 7 years ago

https://www.reddit.com/r/rust/comments/27sbgr/oop_in_rust/

carols10cents commented 7 years ago

https://internals.rust-lang.org/t/syntactic-sugar-for-delegation-of-implementation/2633