loading...
Cover image for What is the weirdest piece of code that you have written and does the job?

What is the weirdest piece of code that you have written and does the job?

swissgreg profile image SwissGreg ・1 min read

Have you ever written a piece of code that was not exactly the definition of 'clean code' but does what it has to do? (and does it good for a long time?)

Feel free to share it!

Discussion

pic
Editor guide
Collapse
artyomgazizyanov profile image
Artemiy Gazizyanov

One night, being tired and sleepy, I wrote something like this

if(a == true)
{
   doSmth();
}
else if (a == false)
{
    dontDoSmth();
}

In the next morning, when I found this, I decided to leave this code on its place, because it was so embarrassing and stupid, so I monumented it in my code.

Collapse
ankitbeniwal profile image
Ankit Beniwal 🙂

ohh... you missed a check for NULL 😂😂

Collapse
predragnikolic profile image
Предраг Николић

If a can be true, false or null.
In that case the if statement could make sense :-)