Empty try-catch blocks - "Oh shit, this bit of code fails, I can't be bothered working out what's going on, I'll just catch the exception (and any other exceptions that are ever thrown) and ignore it. Oh and I won't bother putting a comment in the code to explain why I'm catching this particular exception, cos I don't really know why I am."
Well, I guess the thought process is something like that.
Pointless member variables - OK, so you know what a class is and you know what a member variable is, but that doesn't mean every single variable has to be a member variable. It doesn't make your code more object-oriented, it just makes it more complex. If it's only used in one function, then it probably only needs to be declared in that function. In a managed environment, it means the variable goes out of scope earlier and doesn't have to live for the entire life of the class instance. And your code is more maintainable. Although I'm guessing maintainability wasn't the prime concern of whoever wrote this app...
No comments:
Post a Comment