Your Code isn’t Correct
Tags: cleancode, programming, architecture
Published: 2021-12-09 14:08:36

---
title: Your Code isn’t Correct
published: true
date: 2021-11-29 15:23:57 UTC
tags: CleanCode,programming,architecture
canonical_url: https://qvault.io/clean-code/your-code-isnt-correct/
---

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u0i81h2zvo0w0oty6in.jpg)

The post [Your Code isn’t Correct](https://qvault.io/clean-code/your-code-isnt-correct/) first appeared on [Qvault](https://qvault.io).

There is a common trap that we fall into as developers, and it is believing that because some code “worked” that the code was written “correctly”. In reality, for most technical problems, a good developer can likely point out several different solutions. Any of those solutions might be perfectly reasonable, while none of them is the single “correct way”.

## Different solutions optimize for for different things

You can only optimize for a few things at once, and there are always tradeoffs. Bloated memory consumption often makes way for faster computation speed. Simple syntax often leads to a lack of control or configurability. Different solutions to the same problem often optimize for slightly different things. I’m personally a fan of [optimizing for simplicity first](https://qvault.io/clean-code/optimize-for-simplicity-first/), but “simple” means different things to different people.

In some cases, short and concise variable names might be simple. In some cases, a longer name with 4 or 5 words might be simpler.

Firestore as a storage engine might be simple because it’s “basically just persisted JSON”, but leads to data duplication. It might make reading data simple, but adds complexity at “create”, “delete” and “update” time.

Vanilla JavaScript is “simpler” than a giant React framework at first. Once your app grows so large that you begin rewriting reactive libraries into your own code, React would likely be “simpler”.

In short, when you’re reviewing someone else’s code, and it looks different from how you would have done it, try to see if they’re making improvements in areas where your solution wouldn’t have. Just because your solution does one thing “better”, doesn’t mean it’s better overall.

## Your code can always be better

I _really_ don’t agree with the conclusion of this somewhat popular meme, and I cringe a bit when I see newer developers sharing it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1bnj3scmkzdh77sgsl7.jpg)

If you need to maintain your code into the future, as most of us do, please revisit it and update it! Tech debt is real debt.

- Keep dependencies up to date
- Refactor API contracts to keep them sensical as business rules change
- Upgrade to newer infrastructure and technologies as it makes sense to do so
- Keep your team knowledgeable on the older parts of the system, legacy code can be scary

## Just because code can be better, doesn’t mean it’s a priority

There is some truth to the “1st rule of programming” meme though, don’t get me wrong. There are cases where you don’t want to waste precious time updating or refactoring code. For example:

- You just need a prototype because product market fit hasn’t been found yet
- You know whatever code you wrote won’t be needed for long because a more robust solution is being purchased or built
- You just need a proof of concept
- The client is unwilling to pay for maintenance (in a service-based business)

Be smart. Your solution isn’t perfect, and that’s okay. Continue to iterate and everything will be fine.

Ready to get coding?

[Start writing code for free](https://app.qvault.io/)

[Join our Discord community](https://discord.com/invite/EEkFwbv)

## Have questions or feedback?

Follow and hit me up on Twitter [@q\_vault](https://twitter.com/q_vault) if you have any questions or comments. If I’ve made a mistake in the article, please [let me know](https://qvault.io/contact/) so I can get it corrected!