Ok # 2. Definitely. Without a doubt.
# 1 says, “modify the existing procedure,” causing things to break. This is by no means a good thing! Your customers will hate you. Your code just gets more complicated, so it's harder and harder to avoid breaking things that lead to more hatred. This will go terribly slow and will be impossible to tune. And so on.
For # 2 you have a stable interface. No hate. Hooray! Seriously, "yay," as in "I still have a job!" unlike "boo, I got fired for being annoyed by my customers." Jokes aside. Never do # 1 just for this reason. You know that is true. You know it!
Having said that, write down what people do. Take user id as parameter. Log in. Know your users. Find those who use the old shitty code and ask them to pleasantly update if necessary.
Your reason to avoid the number 2 is distribution. But this is only a problem if you are not testing the material. If you test the material correctly, proliferation still occurs in your tests. And you can always tweak things in # 2 if necessary, or at least isolate performance issues.
If the thicker procedure is really great, then modify the skinny version with the thinner version of the thick one. In SQL, this is difficult, but copy / paste and cut the list of favorite columns. In general, I just did not bother to do this. Life is too short. Having really good test code is a much better investment of time, and the data schema is usually rarely changed in ways that violate existing queries.
Good. Hurry up. Serious message. Do # 2, or at least DO NOT # 1, or you will be fired, or hated, or both. I can’t think of a better reason than this.
emperorz
source share