you are viewing a single comment's thread
view the rest of the comments
[–] 83 points 8 months ago (16 children)

In over ten years of professional programming, I have never used inheritance without regretting it.

  • source
  • hideshow 16 child comments
  • [–] 6 points 8 months ago

    It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).

    In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it's even nicer to use than inheritance.

  • source
  • parent
  • [–] 4 points 8 months ago (6 children)

    That's wild. What did you use it for?

  • source
  • parent
  • hideshow 6 child comments
  • [–] 2 points 8 months ago (5 children)

    Some legacy Python code that already used inheritance. I had to extend it, and it was pretty infeasible to refactor the whole thing to not use inheritance. Not sure if I technically regretted that decision, but it was definitely painful, since Python inheritance makes it really hard to follow program control flow.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 8 months ago (4 children)

    Non typed inheritance, what could go wrong eh. You can just 'add' a function to a class dynamically in python, that is so bad.

    Done any C++ classes & inheritance?

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 8 months ago (3 children)

    It was actually typed. Python had type annotations at the time.

    I only wrote C++ very early in my career so I don't remember much, but I'm sure I at least tried some inheritance in toy games I would write. All of that code was trash though by my standards today.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 8 months ago (2 children)

    Still does, but you don't have to.

    So you haven't had much experience with oop?

  • source
  • parent
  • hideshow 2 child comments