this post was submitted on 03 Jul 2023
100 points (96.3% liked)

Programming

17319 readers
107 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Bytestream@programming.dev 2 points 1 year ago (3 children)

C++ dev with minimal experience of composition here, but this is a great article and it's something I've been trying to play with more and more. Out of curiosity, does anyone know if there are any known big pitfalls to avoid with composition (thinking of things like the diamond problem)?

[–] colonial@lemmy.world 4 points 1 year ago* (last edited 1 year ago) (1 children)

The only thing I can think of: you often need to strike a balance between having interfaces that are too generic/large or too specific/small. However, you already have to worry about that in OOP (God Object vs ravioli code) so it's not a huge deal.

Another reply suggested giving Rust a try, and I do second that. But if it's not your cup of tea, at least take a look at some of the standard library traits - std::io::Read/Write and std::iter::Iterator will give you a good idea of what composition can do.

[–] Bytestream@programming.dev 2 points 1 year ago

Thanks for the info! I have been very slowly making my way through the Rust book, hardly made a dent so far but am enjoying it.

load more comments (1 replies)