News for hackers. Stuff that matters.
Re:Goodbye, Clean Code by tsimionescu on Saturday January 11, 2020 @07:23PM (#22023457)
That works until you have 20 different Big Ol' Switch Statements, each switching on (mostly) the same cases, essentially implementing a set of related behaviors in 20 different places instead of grouping the 20 behaviors under the same umbrella.

Overall, I think there is an equilibrium between the number of cases in the switch and the number of different switches with the mostly the same cases. The fewer cases ypu have and the more times you handle the same cases, the more it will help to group these different behaviors in separate places: each case would correspond to a different class, each switch statement to a different method in each class. The fewer classes and the larger they are, the more I think it helps to apply this transformation.

By the way, this has nothing to do with the discussion above. The alternative to the switch that GP commenter presented isn't polymorphism, it is simply extracting the common lines into a separate function.

Re:Goodbye, Clean Code by marcus_holmes on Sunday January 12, 2020 @05:39AM (#22025600)
you're entirely right, of course. I just wanted to express my enthusiasm for the approach :)