Live data from Hacker News

Shit programmers write

shitprogrammerswrite.com

61–70 of 82 posts

Re: Shit programmers write

#61
For the "Siamese HTML Document" -- that one rings a bell... I swear there was a bug in one of the ancient horrible versions of IE that required you to include your "no cache" tags AGAIN in a second head tag, if you wanted to use http-equiv tags instead of real HTTP headers.

I'm pretty sure there hasn't been reason for anyone to do that for a decade or so, though.

Re: Shit programmers write

#62
post #47

public bool ShowOptional() { bool bolReturn = false; return bolReturn; } The above actually seems reasonable if you assume the programmer that wrote it was intelligent. I'm imagining that the above code is called multiple times by the application, for a new optional feature in development. Currently, they haven't developed the feature, and so we are always returning false. But in the future, we likely will want to sh…

Why have a variable then?

  return false;
Done.

Re: Shit programmers write

#64
post #13
post #7

Earlier quoted context omitted.

This reminds me of this one, which is quite common: return foo == null ? true : false;

I sometimes do that in PHP because I hate the equivalence between "", false, null, '0' and 0. Seeing true and false written out makes it more readable.

When you find your language forces you to do stupid things, the correct response is not "get in the habit of doing stupid things". It's "find a better language".

Re: Shit programmers write

#65

Earlier quoted context omitted.

From my experience, such code is not specific to MS technologies, but is indeed often found in “enterprisey” code, a lot of which just happens to be in Java and C#. And enterprisey code is like that because it's often outsourced to the lowest bidder. I once had to print a method that took 50 pages of paper, so I could understand what it does, and after 15 minutes I realized it's the same 60 lines repeated over and ov…

Just curious: Why does printing it on paper helps you to understand code better than reading it on screen?

Because if you can find a room with enough table space you can lay out all of the code at once instead of having to jump back and forward on a small screen.

A 4x6 table has far more surface area than even the biggest multi monitor set up

Re: Shit programmers write

#66
post #47

public bool ShowOptional() { bool bolReturn = false; return bolReturn; } The above actually seems reasonable if you assume the programmer that wrote it was intelligent. I'm imagining that the above code is called multiple times by the application, for a new optional feature in development. Currently, they haven't developed the feature, and so we are always returning false. But in the future, we likely will want to sh…

If that’s the case shouldn’t they have just used

    public bool ShowOptional()
    {
        return false;
    }

?

Re: Shit programmers write

#67
post #47

public bool ShowOptional() { bool bolReturn = false; return bolReturn; } The above actually seems reasonable if you assume the programmer that wrote it was intelligent. I'm imagining that the above code is called multiple times by the application, for a new optional feature in development. Currently, they haven't developed the feature, and so we are always returning false. But in the future, we likely will want to sh…

Why have a variable then? return false; Done.

I used to write this kind of snippet when creating the skeleton of a function, this seems like a leftover that was over-sighted in the code review (assuming that there was a code review at all)

Re: Shit programmers write

#68
post #16

A lot of these seem to be attempts to fit into existing "best practices". Unit tests that prove nothing. Boilerplate Java code that does nothing. Maybe we should reevaluate some best practices. I have debated before on here that many unit tests seem useless as the units are too small, and you essentially end up testing your language or framework which you already know works. Integration testing on the other hand make…

> When I started with Java, it seemed appropriate to put hundreds of getter / setter methods. Is there much advantage to that over allowing the variable to be accessed directly?

Oh my yes. As soon as you need more than one processor messing with an object they are invaluable. The only thing better is immutable objects.

It's also nice to have the object interface separate from object data if you want to change the object data representation without breaking everything (I don't know in general when you would do this, I just know I have done it before and getter/setters let me work faster to refactor).

Re: Shit programmers write

#69

Love this one: return foo == null ? null : foo;

That one makes a bit of sense in Javascript as it'd return null if foo was null OR undefined.

It might be technically correct, but if the intention was a loose comparison surely don't include null in the comparison?

  return !foo ? null : foo;

Re: Shit programmers write

#70
post #43

I wonder how much of that is due to problems in documentation/documentation discoverability. This seems precisely the kind of data that we need to make docs better.

Or, you know, write programming languages that don't suck. See also https://www.destroyallsoftware.com/talks/wat
Post reply on HN