Follow @RoyOsherove on Twitter

Mortal sin: Just "Doit"

You've been there before, right? a big ass method (200-600 lines ) with a mess of SQL, logic and “SELECT * from...” in it. And it's called... “Doit”. Yep. I swear.
But then it got worse.
A method just as big, looks practically the same, named... aha. “Doit1”. I kid you not.
 
Can you guess the problems arising from such code, kids?
Can you guess how many serial killers got started the day they had to maintain such code?
 
Solution: Don't Doit.
  • Give a good name to your method that describes what it's trying to do.
  • Make sure it only does one task and calls other methods to do other stuff.
  • Learn what Refactoring means.

Weekend off

Mortal sin: A non-relational relational database.