• magic_lobster_party@kbin.run
    link
    fedilink
    arrow-up
    0
    ·
    6 months ago

    On the contrary, it made it far more difficult to understand the program since you had to know which method was called in which object due to polymorphism when you looked at the code. You had to jump around like crazy to see what code was actually running.

    I agree with this point, but polymorphism is often the better alternative.

    Using switch statements for the same thing still have the problem that you need to jump around like crazy just to find where the variable was once set. It also tends to make the code more bloated.

    Same with using function references, except this time it can be any function in the entire program.

    The solution is to only use polymorphism when it’s absolutely needed. In my experience, those cases are actually quite rare. You don’t need to use it everywhere.

    • 1984@lemmy.today
      link
      fedilink
      arrow-up
      0
      ·
      6 months ago

      Yeah I agree. With experience you know where to use it and where it really shines, and when not to use it because it will just make everything harder to reason about.

      But a lot of devs are not that experienced when they make these decisions. All of us learn from mistakes, and those mistakes stay in the code base. :)