📜 ⬆️ ⬇️

Good code is our best documentation.

Hi Habr! I offer you a free translation of the article " Good code is its own best documentation " by Amit Shekhar .

image

Good code, like a good joke - does not require explanations.

If your code is simple and straightforward, then for the most part, it does not need comments and documentation.
')
A good code is like a car with excellent stereo and cup holders, which accelerates to the limit without any problems. When it breaks, any mechanic can fix it in a short time using ordinary tools.

Bad code is similar to a car that promises to be able to reach 120 km / h, but has a stereo that only accepts cassette tapes, and coasters have sloping bottoms. Every time you try to adjust the mirrors, the car explodes in a flame and needs to be repaired by a specific person who assembled it on the assembly line using its unique tools.

Good code is like a well written tutorial.



Bad code looks like a badly written textbook.



This is what is important to remember if you want to write good code:



Code quality check


Show your code to another programmer who has not yet seen it, and let it try to explain what each module does, and listen carefully.

The more you want to interrupt and explain in your own way, the more likely your code is worse.

If you can listen quietly and silently, and the person next to you explains everything and does not ask questions, perhaps your code is good.

Signs of good code:



Good code is modular


Suppose there are three layers in your project - inner, middle and outer.

Your inner layer should not know anything about your middle or outer layer. Your middle layer should not know anything about your outer layer.

In this way, your inner code layer can be tested independently.

Read more about this in this article ( Link translator )

“Good code is our best documentation” - Steve McConnell

Source: https://habr.com/ru/post/335400/


All Articles