CodeSOD: Switched On Readability
by Remy Porter from The Daily WTF on (#7A3JF)
Jon has a team mate that has a coding quirk. They tend to write this pattern a lot.
switch (someEnum){ case EnumType::TargetValue: doStuff(); break; default: doOtherStuff();}Specifically, they have these single branch switches. Usually when using enums, but they've even done it for booleans a few times, like:
switch(someBool){ case true: doStuff(); break; default: doOtherStuff();}It's not 100% true that they eschew if statements, but they rarely use them. They write basically any condition via a switch. Why? No one knows. Not even them. "I just think it's easier to read."
[Advertisement] Plan Your .NET 9 Migration with ConfidenceYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!