【 introduction:

In the book Clean Code written by Robert C. Martin, it is proposed that the Code quality is proportional to its cleanliness. Clean Code is not only reliable in quality, but also lays a good foundation for later maintenance and upgrade, thus revealing the Code cleanliness. The article describes: When you are doing a Code Review, you can know whether the Code you have written is Bad Code or Good Code from the calm or fierce words of the reviewer. This may be the scene that engineers often encounter. Whether you can write “high-quality” Code may also be the test of a “high-quality” program must solve the problem.

Code is the programmer/engineer’s weapon. Non-standard code can have many negative effects, such as inconvenient review reading, increased maintenance complexity, and reduced team productivity. On top of that, non-standard code can potentially cause bugs, such as parameters, exception handling, logging, and so on. Elegant code is pleasant to read, easy to understand, and helps with refactoring later.

On Thanksgiving Day, we would like to give our programmers a small Thanksgiving bonus — a “thank you” for working with them all the time. We would like to thank our technical partners for their continuous pursuit of excellence, but they do not know that the lines of code under their fingertips make the audio and visual experience more beautiful

In order to help you know more about the “caring” programmer community, it also helps the programmer to exchange and share experience. Xiaobian specially invited 5 excellent iQiyi program monkey Gege, with their years of experience, to talk about programmers to write code that thing ~

What does good code look like? * * * * * * * *

Key words a

legibility

“People may think readability is too easy, but what seems to be the easiest is the hardest.”

MartinFowler, a noted author and international speaker on software development, said, “any fool can write code that a computer can understand. A good programmer is one who writes code that humans can understand.”

Code is read first by people, second by machines. Readability should be one of the first criteria for code. Because writing code is not a solo job, it is a team effort, and being able to be read by others is very important. Second, the greater benefit of writing “human-readable” code is to improve its maintainability. Most of the code needs to run for at least a few years after completion, and the development of the code is actually only a small part of the entire product life cycle, with most of the time spent on maintenance. Bugs are sad enough, and if you’re trying to fix a Bug and the code isn’t written in “human language”, it’s pretty bald. Therefore, it must be readable in order to be easy to maintain, but readability is only the minimum requirement for iQiyi programmers.

Keywords second

scalability

If legibility is a basic requirement, then scalability is the “advanced requirement” for iQiyi programmers. In the Internet era, “shoot first, aim later”, innovation and efficiency are our magic weapons to win in iQiyi. All products are constantly updated and iterated, so the scalability requirements for products are very high.

Scalability seeks to expand more functions without modifying the original code, which has the advantage of high efficiency and reduced development costs. That is to say, we should not only bow to pull the car, but also look up at the road. On the basis of completing the existing product needs, think more about a few steps to pave the way for the “future”.

Key words

High cohesion and low coupling

High cohesion and low coupling is also one of the criteria for iQiyi programmers to judge the quality of their code.

“High cohesion” is used generally to judge the quality of the software design standards, jargon called “functional cohesion”, highly cohesive software elements in the system has high collaborative, because in our a function in the complete software requirements may need to do all sorts of things, but one of the elements with high cohesion, it’s only to complete its duties, It asks others to do things that are not its responsibility.

“Coupling” is a measure of the connections, perceptions, and dependencies between an element and other elements. “Low coupling” means that the boundary between one’s own module and other modules should be clearly demarcating, so as to reduce interdependence and avoid the occurrence of “affecting the whole” as much as possible. Achieving “high cohesion and low coupling” can effectively improve code maintainability and maintenance costs, as well as increase its changeability.

When writing the code ********

What are your good habits and experiences to share? * * * * * * * *

Tools a

code review

Regular code review is a necessary injection of amway!

It is a good way to do coding, whether it is to stop and review your code regularly or to conduct code review among teams.

WTFs/per min (WTFs/per min) is a term used to describe how often you re-examine your past code, looking for defects, functional implementation problems, code rationality, performance optimizations, etc. Improving code quality can also lead to early detection of potential defects, reducing the cost of fixing/fixing defects.

Through the interview, XIAobian also learned that every team in IQiyi basically has its own code review mechanism. In addition to promoting knowledge sharing within the team and improving the overall level of the team, review process is also a process of thinking reconstruction for team members, which can help more members understand the system.

 

Two tools

Make use of comments

Nie from the product research and development department in the background pointed out that annotations are an important tool that many programmers ignore. These days most people write comments just for the sake of writing them, and most of them simply describe the implementation layer. But actually, there should be more commentsDescribe the relevant content of the design intention, or add illustrations. In this way, code design ideas can be better recalled in the process of code review, which is conducive to code maintenance and reconstruction.

 

Three tools

Learn more excellent source code, repeat the wheel

For programmers, the wealth of open source code on Github and other “straight dating clubs” is an invaluable asset. If you can fully learn and make good use of open source resources, you can not only learn the basic content of code writing specifications, design, but also master a variety of programming methods, improve practical ability, but also get good ideas, inspire programming inspiration. Iqiyi itself has excellent open source code, such as QLB, has a certain influence in the industry ~ (we can learn more oh ~) \

“You learn more by re-building the wheel by learning good source code, and sometimes you learn more by trying to imitate something similar. “

What do you think are the core qualities a programmer should have? * * * * * * * *

A,

Abstract layer build \

Many programmers pay more attention to the implementation layer when writing code, focusing on how rather than why, which will lead to poor scalability and chaotic architecture of many systems, and collapse of a large area when changing. Therefore, for programmers, the establishment of abstraction layer is particularly important, we need to pay more attention to the internal logic.

This is very similar to our OKR formulation, O is the abstraction layer of the system, why, O remains constant, and KR is our code, which is the tool to implement O, how.

Take a simple example: if we develop a mobile calendar app, users can upload text or pictures. So in the background processing, we distinguish the text corresponding to red and the picture corresponding to green. Programmers need to make it clear that we’re doing this for the type of content, not just color.

Therefore, we need to separate ourselves more from the mechanical coding and understand the internal logic of system establishment, which plays a crucial role in the establishment of the overall system.

Second,

curiosity

Curiosity is also an essential quality for programmers.

No curiosity, no drive. The Internet industry develops rapidly and changes rapidly. The technology mastered will soon become obsolete, and the existing concepts will soon become outdated. Therefore, curiosity is required to step out of the comfort zone, take the initiative to understand new technologies, new ideas and new ideas, and timely grasp the industry dynamics. In this era of information explosion, extract useful ideas and content, into their own knowledge framework, learn to apply.

Three,

Team spirit \

Software development today is no longer the era of individual heroism of 20 years ago, and it is rare that a single superprogrammer can do everything. We’ve moved from individual to team mode, so teamwork is becoming more and more important as we design and develop systems as a team.

Setting a clear, shared goal, complementing each other’s skills and contributing to that goal, is what a good development team looks like.

 

Here comes the dry stuff! Recommended books/papers ****

List of major Books:

Refactoring – improving the design of existing code by MartinFowler

The Code Clean Way. By Robert.Martin

Java Development Protocol Chinese language Project team of Alibaba Group

Kubernetes official documentation

Agile Software Development Principles, Patterns and Practices — Solid Principles

Design Pattern (dimensions above solid principles) — software, key patterns, literacy. Template, go board score, the feeling of fixed moves. Landing the above principles of the set routine

Code Complete — A technical encyclopedia

Clean Code — Code style

Egg book list:

The programmer must read the survival guide

Interactive topics:

Could you tell me the list of useful books in your field?

Leave a comment below the tweet and the top 7 who get the most likes will get exquisite gifts customized by iQiyi

end

Maybe you’d like to see more

The multiple identities of programmers you don’t know

Code Quality Improvement: Code coverage principles and mobile engineering practices

Scan the qr code below, more exciting content to accompany you!