DEV Community

Cover image for Code Pixel - Keep it lean
Valentin Prugnaud 🦊
Valentin Prugnaud 🦊

Posted on • Updated on

Code Pixel - Keep it lean

How to keep your code lean and simple to prevent tech debt:

1 - Avoid nesting

Alt Text

Try to avoid nesting your conditionals and loops. They can quickly add up and increase complexity. There are times when you have no choice and nesting could reduce complexity, but in general this Is a good practice.

2 - Naming is hard

Alt Text

Naming is hard. But take the time upfront to name your variables, methods and classes appropriately, it will pay off in the future.

You will be able to understand your code more easily and most importantly: new team members will be able to navigate your codebase quicker when joining your company.

3 - No comments…

Alt Text

…okay maybe a few. Try to use your comments to add more context, or point to extra documentation/resource that can help understand the piece of code below. Avoid redundant comments simply repeating the name of the method, especially is you have proper naming, as it won’t provide more context and make the code bloated.

4 - Don’t overthink it

Alt Text

Good code is most importantly code that works.

You can always come back to your code later to improve scalability or performance. Keep it lean and simple, it will prevent tech debt and your teammates will thank you.


  • reduce your method size. I personally like to keep my method under 25/30 lines long.
  • Extract complex conditionals in methods and name them appropriately: isUserAuthenticated(), isOrderComplete etc…

You can also find these pixels on my Instagram: I will publish Pixels every Monday, Wednesday, and Friday about career development in tech, code, mental health and health for developers. Follow me for more tips @valentinprngd and check out my podcast

Top comments (0)