I hope this series becomes popular enough for bad developers to notice code like this. Because these code is really what’s out that! I’m serious! Next up, abuse of try-catch. This is how type validation is done. Wonderful, isn’t it? And look at the wonderful booleans associated with the try-catch logic? Doesn’t that just make you cringe?
int index = 0;
bool isInputValid = true;
bool isSingleDayLeave = true;
// dateStart is a string assigned from above this code snippet
newDateStart = Convert.ToDateTime(dateStart);
errorMessage += index + ". Date start should be given.<br />";
isInputValid = false;
// dateEnd is a string assigned from above this code snippet
newDateEnd = Convert.ToDateTime(dateEnd);
isSingleDayLeave = false;
isSingleDayLeave = true;
// … more of similar code below.