Cobwwweb logo

If You Hate the Code You're Writing...

Jan 25, 2019

Stop it!

If you hate the code you are writing, why are you writing it?


I've experienced four scenarios in my career in which I've hated the code I've written:

  1. I worked for an agency that pushed speed over quality. I didn't have time to get much better writing code because everything was an emergency all the time. I pleaded and was constantly denied the time to write tests. I shipped shitty code to every single client.
  2. I was learning a new language or framework.
  3. I was writing in a language/framework that isn't fun for anyone, like Angular.
  4. It was self-inflicted – for one reason or another the code I was writing was bad even though I knew the language and had time to write it better.

And here's what I did to remedy each of these situations, respectively:

  1. I quit the job in search of a place where I had more control over the code quality.
  2. I powered through until I was either good enough that the language/framework was fun or advanced enough to accept that it is no fun for anyone.
  3. I have three approaches for dealing with a language I don't like.
    • If it's a one-and-done project, I just suck it up and do the work.
    • I attempt to find a way to make it fun by writing it in my own way (which is not ideal for me or the client or any other developers who may work on it). Or three,
    • I (usually with the help of others) attempt to convince the client or agency to go a different direction.

    If all these fail and I approach a last resort, I weigh my options. If I want to keep my job, I just do the work in that language (the suck-it-up approach). Otherwise, I'd quit. I've yet to hit a last resort with a language I don't like yet.

  4. I refactor the code.

There are so many programming languages out there today. You couldn't even learn enough to know which ones you shouldn't use, let along figure out which one is best for the the job. And there are an abundance of tools, frameworks, and jobs for every popular language.

So, if you find yourself writing code you hate, ask yourself why. Attempt to remedy the situation. And if it comes to a last resort after the remedies dissipate, weigh your options and either suck it up or move on to something new.

Life is too short to write unsatisfying code.

Write code you love.

Did you learn something or find this article interesting?

If so, why not