What Clean Code Really Means?

I think there's quite some misconception about what writing clean code really means. Here's my take on what clean code isn't and what it is:

What isn't really clean code:

  • Code formatting: Clean code is barely about proper indentation, spacing and formatting, it goes deeper than that.

  • Adding More Comments: While comments can be helpful, excessive commenting can clutter the code and make it harder to read. Clean code should be self-documenting to a large extent.

  • Excessive Code Splitting: Without taking away the absolute importance of code splitting, unless you are reusing or categorizing a piece of code, too much code splitting just makes folders unnecessarily bulky.

    What clean code really means:

    • Following the industry standard: This can be as simple as using camel casing with JS and snake casing with python. Always try to write your code following the community standard.

    • Meaningful naming: Whether its variables, objects or functions, declare them with a self explanatory name, even if the name is long. If you must declare them (functions or objects especially) using abbreviations, add a comment with the full meaning. PLEASE!

    • Use libraries: If you're a creative engineer like me that thinks he can write a function to safely land a rocket on earth, you understand this. No matter what it is, if there's a library for it, please use the library. Libraries are often built with efficiency and scalability in mind, you most likely will not create that functionality better than the library that just does it for you.

    • Code splitting: I know I mentioned code splitting as part of what clean code isn't, but that is only when it is done excessively. Even if you are not reusing a piece of code, if the code becomes too large, it is better to just put it in a separate file, and then always remember not to repeat yourself. These are great instances where code splitting makes your code clean. It's a matter of know when and when not to do it.

      This is my take on what code splitting is and isn't. What did I miss?