The Worst Single Line of Code I Have Ever Seen?

One Bad Line of Code

And it had such potential!

 
Web development Javascript code screenshots.

Now I do try to be a kindhearted person, and upbeat team member, and dare I say an optimist (well I try anyway). But sometimes in the trenches we see things that just can’t be unseen. This is one.

You can bet your boots I rewrote this little gem but not without a tiny bit of headscratching.

if(!$this->session->userdata('is_logged_in')==TRUE){
    // do something
}

The “do something” is my annotation for brevity.

If you don’t read code very well, it translates to this in plain english: “If is false that this user is logged in is true, do something.”

How tired was the person who wrote this and what kind of deadline were they under that this seemed the logical solution? It’s not malicious, it isn’t buggy, and it did work. But it sure was ugly. I take particular offense to the double equals == (this is a job for the triple ===) and lack of spacing. Tsk!

Last updated on