Attack of the Lazy Coder
I'm having such a great time dealing with lazy code. Check out these gems I've found just today ...
var periodError
= string.Format(
"The Survey Return does not contain a valid Reporting Period");Why format something that with no parameters? I changed the code to this:
var periodError
= "The Survey Return does not contain a valid Reporting Period";Here's another good one:
var periodError
= string.Format(
"The specified period {0} does not match the expected period of {1}.",
surveyReportingPeriod.ToShortDateString(),
aReportingPeriod.ToShortDateString());Let's completely avoid the format specifiers and convert everything to strings manually. I changed it to this:
var periodError
= string.Format(
"The specified period {0:d} does not match the expected period of {1:d}.",
surveyReportingPeriod,
aReportingPeriod);What I'm finding really frustrating is that I know the developer who wrote this code, and he's a smart guy who writes good code most of the time.
Upon reflection, I'd suggest that this code is less important for the actual errors, and more as a reminder that we all can make those errors, even (or especially) those of us who think we're pretty good at what we do.
Recent comments
3 days 21 hours ago
3 weeks 1 day ago
3 weeks 2 days ago
4 weeks 5 days ago
4 weeks 6 days ago
9 weeks 3 days ago
10 weeks 2 days ago
10 weeks 2 days ago
10 weeks 3 days ago
12 weeks 6 days ago