2 Matching Annotations
  1. Oct 2022
    1. The compilation will fail in case any new shape is added and not handled somewhere.

      Yeah, in rust you can do this. The program wont even compile if not all cases are handled. No need for the exception.

    2. Having no if or switch statement is a huge win. (...) You can see how code like that grows and grows as new shapes get added. The code itself is complex, as all conditionals are. They have extra possible execution paths through the code. Each one needs testing. Each one increases the chance of coding mistakes. This switch statement prejudice is a constant of OOP, as far as I can tell. Anytime polymorphism is explained, it's contrasted with a “scary” switch statement.

      Yeah, I've noticed this. The argument is that if a new type is added you may need to update many switch statements to support the new type.