Live data from Hacker News

Weekend project: A place to post crappy code. HatePaste

hatepaste.com

1–10 of 33 posts

Re: Weekend project: A place to post crappy code. HatePaste

#10
It's interesting that this is one of the most hated (http://hatepaste.com/paste/f5da3584):

  if (someBoolean == true) {
      doSomething();
  }
I got into the habit of doing this since it's immediately obvious that the value you're comparing is expected to be a boolean and not something like an integer, which could cause subtle bugs later on if what you thought was a boolean gets negated. More commonly, it's of the form:

  if (someValue == false) ...
rather than:

  if (!someValue) ...
to distinguish this from:

  if (someValue == 0) ...
It only takes an extra fraction of a second of typing and increases clarity for the next developer, or for you six months later. Anyone else do this too?
Post reply on HN