After a miserable afternoon spent debugging the code another developer wrote, but didn't have a chance to test at all before he left the company, I am forcibly reminded of the need to always put a begin and end in every if statement even if there is only one line after the if. This silly thing has 42 if statements spread out over stored procedure that is over 12 printed pages long. (It also has 27 input variables, Ugh, Ugh, Ugh! Testing hell!)
Some of these statements have begin and end and some do not, but the spacing doesn't indicate to me whether they next two lines or so should also be in the if or not (given what the statemetns are trying to do, it could go either way, although including them makes more sense to me). I haven't gotten past the pure typing errors and mismatches between the variable data types and the data that actually will be supplied to really see the effect of leaving the block off would have since it never gets to the point of actually building the dynamic sql statement and running it.
At least if he had consistently put in the begin and end statements, I would know which path he intended to follow. It's also easier to maintain the code if later on you need to go from one to more lines (really easy to forget to do this when changing an if statement becasue you expect them to be there.
Sorry for the rant, just needed to vent and wanted to remind everyone to think about their coding practices since they may not be the person who ultimately has to deal with their code.
Some of these statements have begin and end and some do not, but the spacing doesn't indicate to me whether they next two lines or so should also be in the if or not (given what the statemetns are trying to do, it could go either way, although including them makes more sense to me). I haven't gotten past the pure typing errors and mismatches between the variable data types and the data that actually will be supplied to really see the effect of leaving the block off would have since it never gets to the point of actually building the dynamic sql statement and running it.
At least if he had consistently put in the begin and end statements, I would know which path he intended to follow. It's also easier to maintain the code if later on you need to go from one to more lines (really easy to forget to do this when changing an if statement becasue you expect them to be there.
Sorry for the rant, just needed to vent and wanted to remind everyone to think about their coding practices since they may not be the person who ultimately has to deal with their code.