Friday, April 18, 2014

Bad Code: Don’t abuse the “if”

Couple of things I don’t like with this code,
  • “if” does 2 things, it adds a car to the collection and checks the status.
  • I like if condition flow from left to right than right to left, it feels more natural language.
Keep “if” side effect free, don’t do any logic other than checking. Less code is not always clear code.