|
|
|
|
|
by fishtoaster
733 days ago
|
|
This is pretty much what I've come to over the years. It kinda feels like the "IQ Bell Curve" meme: Beginner: I'll just create an if statement with 3 clauses. Middle: No! that's clearly a ton of duplication - it's bad code! Expert: I'll just create an if statement with 3 clauses. And I can see how people get to the middle position. People often tell beginners to eschew duplication. They learn to see any trio of similar-looking lines as a code smell and jump to refactor. It takes a few years of doing that and getting burnt by it before you can really differentiate "this is duplicative and would benefit from refactoring" from "this only looks duplicative, and is actually cleanest with the repetition in place." |
|