How to keep your code lean and simple to prevent tech debt:
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.
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.
…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.
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:
You can also find these pixels on my Instagram: https://instagram.com/valentinprgnd. 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 https://rebased.whatdafox.com.