Good code is reusable, maintainable, scalable and performs well.

Reusability

There is a popular maxim:

When in hurry, copy-paste. And later refactor.

When we think reusability, we think about reusable components or reusable packages.Some sort of utility. Which can be reused all over. But reusability is much more than that. If two methods look similar, create another method. Call the third method for each of the two methods. Doing that will ensure we do not repeat ourselves. It improves productivity. Especially, when there is some enhancement.

Maintainability

Some engineers use cryptic code and make the code less readable. Others do not have a consistent style. Good code is readable and has a consistent style. According to Martin Fowler,

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Linting is an useful technique to promote consistent styles. In the JavaScript world, ESLint does a great job at linting.

Scalability

Why do we have to worry about scalability? Popular websites receive hundreds of requests per second. Usually, we handle a high throughput using multiple servers. As the business grows, the website receives more requests. With new growth, the website receives thousands of requests per second. Is it possible to handle the higher load by adding more servers? It is possible only if the code is written for scalability.

Scalability is a run-time attribute of code. An example of non-scalable code is using stored procedures for business logic. It is difficult to horizontally scale database servers. But easier to scale application servers. Moving heavy processing from database servers to application servers enable scalability.

Performance

Good code should use known algorithms and perform well. Naive programmers use brute-force and write poorly performing methods. Good programmers pick an algorithm best suited to their needs and build upon it.

Good code should take care of Reusability, Maintainability, Scalability and Performance
Tagged on: