Article 3MBZ6 CodeSOD: Without Context

CodeSOD: Without Context

by
Remy Porter
from The Daily WTF on (#3MBZ6)

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.

buildmaster-icon.png [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how! TheDailyWtf?d=yIl2AUoC8zAm90WYPGsCxk
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments