What are the 10 points for writing 'good code'?



When a programmer writes code, he or she should try to write 'good code' as much as possible, such as ensuring maintainability and maximizing performance. Charles Axel Dine , an engineering manager at Uber, explains 10 key points for writing 'good code.'

10 principles for good code | dein.fr
https://www.dein.fr/2015-10-01-10-principles-for-good-code.html

◆ 01: Good code is innovative
If the problem you're trying to solve by writing code is a classic problem, such as 'moving people between cities,' software or hardware may be able to provide an innovative solution. In addition, even in fields where computers are already used, it may be possible to provide users with a better experience than ever before.

Even if the products that your code produces are valued by others as innovative, there are always more innovative products somewhere in the world. Therefore, it is necessary to keep innovating by always paying attention to 'which function of software or hardware can be used to solve the problem' and 'how to provide a good experience to the user', Mr. Dyne said. Is talking.

◆ 02: Good code has clear function
The purpose of writing code is not to 'code' itself, but to solve problems and make the product a 'good product'. A 'good product' is not just 'functioning', but also has 'excellent function' and 'excellent design' to satisfy users. Therefore, when writing code, it is necessary to try to make the function created by the code a clear design for the user.



◆ 03: Good code is beautiful
When writing code, you need to make it easy for others to read. 'It takes a very long sentence to explain how to write beautiful code,' Dyne said, citing several points to keep in mind when writing beautiful code.

· Ensure code style consistency
・ Write in a structure that clearly expresses your thoughts
-There are no comments such as 'I'll do it later' or 'Correction required' in the code.
-Consistent rules for variable names and comments
・ Ensure code reusability

◆ 04: Good code helps understanding the product
Good code clarifies the structure of the product and allows the user to intuitively understand the function of the product. Bad code, on the other hand, can interfere with product understanding.

Dyne recommends that you document your code as a way to see if your code interferes with your understanding of the product. Dine explains that if you need a lot of annotations to fill the gap between product functionality and code when writing documentation, there is room for improvement in the code.



◆ 05: Good code doesn't get in the way
Dine argues that the code is a tool to serve its purpose and should not be over-decorated. Therefore, Dine points out that code abstractions, the use of flashy data structures, the use of complex libraries, and the reinventing of the wheel should be avoided.

◆ 06: Good code doesn't lie
The code does not make the product look more innovative and valuable than it really is. It does not appeal to users the functions that are not actually installed.

Also, if the management of the development company is going well and the work of the engineer team seems to be affordable, it is tempting to consider adding excessive functions to the product, but that function addition may be useless. It is necessary to carefully judge whether or not the wheel will be reinvented.

◆ 07: Good code lasts a long time
Good code, unlike fashion and design, doesn't get out of date and stays useful for a long time. However, most libraries and frameworks will be unmaintained in a few years. Therefore, when writing code, careful technology selection is required, such as adopting withered technology that has been used for many years, or adopting technology that has been compared and verified.



◆ 08: Good code is thorough in every detail
When building the Minimum Viable Product (MVP) for early users, we may ship the product without elaboration. However, Dyne said, 'It's okay to sacrifice a particular use case when building an MVP, but the final product is for all use cases, easy to maintain and easy to fix. We need to. '

Dyne also emphasizes that the final product should be meticulous not only in code, but also in documentation, alerts, test logging and debugging.

◆ 09: Good code is eco-friendly
When running software and hardware, it consumes electricity, which is a finite resource. As a result, Dyne claims that highly efficient code with efficient data structures and algorithms is not only user-friendly but also environmentally friendly.

◆ 10: Good code is short
Dyne reiterated that 'code is a tool, not an end,' saying that the most important challenge in software development is not 'writing code' but 'solving problems.'

And the code should be as short as possible to focus on problem solving. Also, shorter code generally means less maintenance and better performance. Dyne recommends picking out problems to solve or diverting existing products to keep the code short.

in Software, Posted by log1o_hf