CodeSOD: Without Context


When writing up a Code SOD, a big part of the goal is to provide context for the bad code. Why is it bad, what would be better,, etc. In other words, we need to… ShowContext. Vasco O has exactly the method for that.

protected string ShowContext(string context)
{
    if (!string.IsNullOrEmpty(context))
    {
        return string.Format("{0}", context);
    }
    else
    {
        return string.Empty;
    }
}

If the context string has content, return a new string, via string.Format which is exactly the same as the input. If it’s null or empty, return an empty string. This does at least mean that the function isn’t entirely useless- it guarantees no nulls will get returned.

This method was called everywhere, but it did nothing. Vasco removed it.

[Advertisement]

BuildMaster

allows you to create a self-service release management platform that allows different teams to manage their applications.

Explore how!


https://ift.tt/2GMo9V2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: