Once again, we take a look at the traditional “if (boolean) return true; else return false;” pattern. But today’s, from RJ, offers us a bonus twist.
public override bool IsValid
{
get
{
if (!base.IsValid)
return false;
return true;
}
}
As promised, this is a useless conditional. return base.IsValid
would do the job just as well. Except, that’s the twist, isn’t it. base
is our superclass. We’re overriding a method on our superclass to… just do what the base method does.
This entire function could just be deleted. No one would notice. And yet, it hasn’t been. Everyone agrees that it should be, yet it hasn’t been. No one’s doing it. It just sits there, like a pimple, begging to be popped.
[Advertisement]
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Source: Read MoreÂ