• @Bytestream
    link
    English
    21 year ago

    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)?

    • @[email protected]
      link
      fedilink
      English
      4
      edit-2
      1 year ago

      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
        link
        English
        21 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.

    • @[email protected]
      link
      fedilink
      English
      31 year ago

      I don’t know of any. Give Rust a try. Traits and trait bounds will change the way you think about code.