There are certain developers who don’t understand types. Frustrated, they fall back on the one data-type they understand- strings. Dates are hard, so put them in strings. Numbers aren’t hard, but they often exist in text boxes, so make them strings. Booleans? Well, we’ve come this far- strings it is.

Tyisha has the displeasure of working with one such developer, but with a twist- they didn’t really understand strings, either. Tyisha only supplied a small example:

string RequestDate = dteRequestTB.Text.ToString().Trim();
string valid = string.Empty;
string Format = "yy/MM/dd".Trim();
valid = Dates.IsDateValid(RequestDate.Trim(), Format.Trim()).ToString().Trim();
if (valid == "False".Trim()) {
...
}

Now, IsDateValid does more or less what you’d expect- it takes a date (as a string) and a format (as a string), and returns whether or not the input date matches the format (as a boolean).

Tyisha’s co-worker, of course, converts it into a string before comparing. This is dumb, but nothing we haven’t seen before. For a bonus, there’s absolutely no consistency in variable naming conventions. There’s the mix of pascal case, lower case, and a splash of Hungarian notation.

The real magic here, however, is that this co-worker isn’t simply happy calling ToString on everything, but instead needs to also Trim those strings. In fact, they call Trim on every string. Everywhere.

[Advertisement] Atalasoft’s imaging SDKs come with APIs & pre-built controls for web viewing, browser scanning, annotating, & OCR/barcode capture. Try it for 30 days with included support.