How do I learn to write simpler, more efficient code with fewer lines?

there are some techniques that are just solid in making your code shorter and more succinct at no cost. Start with learning map, filter and reduce. They can be used instead of loops and if statements in almost all cases and create code that is much shorter and clearer.

The code of a good programmer is  :

  • Bug-free
  • Clear
  • Performant (but only when it needs to be)

1. Bug-free

A good programmer understands the problem well, and spends a lot of time with each piece of code, thinking about everything that can go wrong, and delivers the code with unit tests. A programmer that doesn’t do these things is passing off that work to the next programmer touching the code and is often destructive to the team.

2. Clear

Good programmers prioritizes understandable code over clever or elegant code. This is because they know that 95% of software development time is notspent writing code, it’s spent inside others code, trying to understand it.

3. Performant (but only when it needs to be)

Good programmers know that to make things performant, you’re endangering point 1 & 2, so they only do performance optimization for parts of code that actually affects end-user performance. Good programmers have a gut feel for what parts of the code this is. Great programmers know that their gut feel is very often wrong, and use performance profiling tools to find out which parts of the code are bottlenecks.

Leave a Reply

Your email address will not be published. Required fields are marked *