Short #2 Leave these parameters alone

lemmings_portal_method_parameters
You’re updating an old method by adding only two simple lines of code at the end, but something is really wrong here. You checked all the method calls and parameters that you’re passing, but they are correct. So maybe their values are incorrect? You run a debugger and check. Nope, they are perfectly fine. The problem might be in the function itself, but it worked like a charm until now, so you’re rechecking your two lines and you still cannot see any issues.

The problem might be the old code in the method. Maybe it doesn’t introduce any bugs by itself, but if it modifies procedure’s parameters at some place, it can cause annoying issues later.

It is like basing the decision about renting an apartment on internet advertisement. The description seems great, the photos are splendid, and the price is low. But when you come to see the flat, it’s dirty, smells bad, and it lacks a fridge. The ad didn’t mention that previous residents damaged it and left it like that. You feel cheated. It would be great if you could just trust an ad, right?

It seems impossible for an advertisement to be honest, but it is doable for the method code. Don’t change the function’s parameters in the body so that you can trust its signature. Of course, if the method is meant to modify its parameters, its name should denote it, or you should use the right keyword (i.e. out in C#) so that the user can be aware of it.

Share these goodies:

Leave a Reply

avatar
  Subscribe  
Notify of