Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What skills are there to improve the ability of the code?

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "what skills are there to improve the ability of the code", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what skills do you have to improve your code ability"?

Language foundation

Many people will probably complain when they see this. Isn't this nonsense? how can programmers write code if they haven't learned how to write a code language?

In fact, it is not nonsense. Different languages have different characteristics and even different principles. If you do not have a solid grasp of the language foundation, it is easy to make some low-level mistakes.

Let's take a simple example. An intern I knew once wrote such a piece of Python code. We might as well see what's wrong with it.

Def funcA (param): if param is not None: return funcB (param) return None def funcB (param): pass

I don't know how many students can see what the problem is. Some students may think that is not None's judgment is wrong and should be written as not is None. In fact, this is not the problem. Is not None is the standard way to judge. It is just a cover in this problem. The real problem is that in the part of the function call, he wrote funcB after funcA.

What's wrong with funcB writing at the back?

If you try it, you will know that writing the Python interpreter in this way will report an error, and we have to write funcB in front of funcA. Because Python is not a compiled language but an interpreted language, it is executed line by line by the interpreter. So it will execute funcA before funcB, and when it executes funcA, it will find that the function funcB does not appear, so it will throw an error.

At that time, the classmate debug for a long time did not find the problem, and even thought it was the problem of the Python version. In fact, it is not that he is not capable of coding, but that he does not have a solid grasp of the language foundation.

There are a lot of similar examples, because each language tends to have a lot of its own features, and if we only dabble in a language, then the code written must be very irregular. For example, if Java does not know abstract classes, and Python does not know variable parameters and decorators, the code written will often look uncomfortable, because not being minimized will give people the feeling that they have made a lot of efforts to achieve a very basic function.

So the language foundation is also the foundation of the code ability, we should not look down upon this, think that as long as you can write the basic grammar. In fact, this is a big mistake, some features and syntax sugar may be used less, but when used at critical times can greatly simplify the amount of code and increase code readability.

Code specification

I don't know if you have read those very irregular codes. I have read some of them, and I really feel like my eyes have been stabbed by a needle.

In fact, the code specification is not the ability, but the engineer's own accomplishment. Highly educated engineers will take the initiative to understand the coding specifications of the current language and will never be comfortable. You can Baidu code specification, each language basically has its own code specification, and this specification is very detailed, specific to the variable name, class name, method name, file name, constant name how to name the corresponding specification.

Not only that, but there are also restrictions on some special cases. Here is a snippet from Google's Java coding specification, which you can take a look at:

The more appropriate the code we write to this specification, the more readable it will be, and the higher the literacy of our coding.

The code specification actually includes not only the aspects of coding, but also many other areas. For example, the use of database connection pool, such as the setting and use of kafka, as well as the use of multithreading, and so on, will have their own specifications. These contents not only play a normative role, but also have corresponding principles in every point, which is worth digging and learning.

For example, many people know that databases need to use database connection pooling, so why use connection pooling? How to set the number of connections in the connection pool? What is the principle of it?

It looks like an interview question, but it contains our understanding of the underlying database connection. We have learned that it may not only be used in coding, but may also be linked together in the future when learning other content. Knowledge is not made up of many points, knowledge is a network, many points need to be connected together. Before we connect, we first need to accumulate enough.

System capability

System capability is the highest requirement of code capability, and it is also the part that best fits the capabilities of an architect.

Again, let's give an example. For example, you take on a task in the team and develop a new system. This system needs to accept 100K requests per second. We do not need all of these requested data, we need to do some sampling, and we also need to query some storage systems for feature filling. Finally, the complete data is stored.

Now that this task is left to you, excuse me, what is the performance bottleneck? How do you design the details of the system?

It is estimated that many students will set their sights on the number of 100K and feel that the number of requests is very large, and whether the system can resist is the biggest risk point. But in fact, 100K is not the point, because these requests do not need to return, just simply receive, 100K is not very large. But there are many hidden questions, such as how do we sample, whether to sample online, or to store all requests for a period of time before sampling? If it is stored and then sampled, will the memory not be able to bear it? For example, what is the order of magnitude of the query requests we will make to the storage system? Will it affect the storage system?

In fact, the process of later practice really occurred that the storage system could not bear it, resulting in a lot of jitter. So after this problem occurs, how should we solve it?

What is needed to be sensitive, understanding and solving these problems is the ability of the system. That is, our ability to understand the system, which involves a lot, we need to have a certain operating system knowledge, distributed knowledge, but also need to have a certain understanding of upstream and downstream systems. For example, knowing that the performance of the storage system is not very good, a large number of requests may not be able to handle. Some of this is experience, and more is our basic ability.

The way to ascend

In fact, after reading these three points, I believe everyone should have some ideas about how to improve more or less.

To put it bluntly, it's no big deal, it's just three points, let's make a simple summary.

It is necessary to consolidate the foundation of the language, not to dabble in the language of learning, but to have a deeper understanding. Of course, this is not just to say, certainly need to do a lot of targeted exercises, but also need to read other Daniel's code to learn.

You need to follow the code specifications, not only the naming of variables and the handling of some special case, but also the system usage specifications in some scenarios.

Need to fully understand the system, carefully deliberate each link, need to accumulate some operating system, distributed knowledge points and skills points.

At this point, I believe you have a deeper understanding of "what skills to improve the ability of the code". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report