Live data from Hacker News

Weekend project: A place to post crappy code. HatePaste

hatepaste.com

21–30 of 33 posts

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

#22
post #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…

Not usually. However, I do sometimes make explicit comparisons to False or None if I can end up with both, and the behaviour differs depending on what I have.

It's probably not the best idea to be doing that, but it's not tripped me up yet ;-)

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

#24
post #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…

Just as long as you don't do this:

    if (someBoolean){
        return true;
    } else {
        return false;
    }

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

#28
post #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…

Wow. http://www.paulgraham.com/avg.html

Are you suggesting I should use Lisp, or that I haven't beat the average, or...?
Post reply on HN