How to solve various bugs efficiently as a good programmer?

 

The first thing is to learn binary search

 

The first thing is to learn binary search. I have seen many programmers who are just getting started. They either learn programming by themselves, have not systematically learned algorithms, and don't even know binary search; or they have finished their undergraduate studies and the algorithms are returned to the teacher. In short, there is no such basic consciousness. . Looking at their positioning problems, starting from the first line of code to add breakpoints or print contextual information, I will have a strong impulse: let me do it.

eg:

If you have a piece of code, such as a function, or multiple functions that call each other, the final result is not what you want, and you should not start from the beginning to find out what went wrong. You should find an intermediate point and start a binary search from there. You check a breakpoint in the middle, or print out the context information to determine whether the state of the program at the middle point is still in line with your expectations. If it meets your expectations, the problem lies behind the middle point; if it does not meet your expectations, the problem lies before the middle point. Repeat this until you can locate the problem.

 

If you can locate the problem, either it is an obvious logical error and you can correct the wrong logic yourself; or it is a lower level problem, you think your logic is correct, but the bottom level The runtime, framework, browser, operating system, etc. are not handled in the way you expect. At this time, you can only learn by searching, why the bottom layer you rely on is not processed as you expected. Your expectations may be right. If the bottom layer is wrong, you have to find a way to get around. Your expectations may also be wrong because you don’t really understand the bottom layer you depend on. At this time, you must continue to learn new knowledge and adjust you. Understand the underlying level, and then modify your code logic.

Keyword search

When encountering this kind of problem, what keywords should you search for? This is a difficult thing to teach, because the ability to search for keywords is very dependent on vision and experience. I have encountered this situation when teaching newbies to program, and also when teaching very experienced programmers to use new company technology.

Teach a novice programming

Teach a novice programming: I told him, if you encounter this problem, you should search for it yourself. He tried to search with keywords he could imagine, but couldn't find the answer. I came to search, the answer is on StackOverflow, or this open source project has already been mentioned an Issue. Why can't he find it? It turns out that he hasn't learned some more complex technical concepts. I can intuitively think of what keywords to use, but he is not aware of the existence of those keywords.

Teach an experienced programmer:

Teach a very experienced programmer to get started with the technology of the new company: I told him, if you encounter this problem, you can search the company’s Internet cafe. Our internal search system is very powerful, Wiki, documentation, discussion... everything can be covered To. He couldn't find it anyhow, but I found it all at once. Why can't he search it? Because he has never heard of certain systems, terms, and code names in the company, and I can think of them all at once, so I can search them.

 

This kind of vision and experience cannot be taught to a new person systematically and at once. Even if you try to pass on a lot of knowledge to a new person at once, he can't remember it all. So the best way to learn is to continue to learn by overwriting disks-I encountered such a problem, I tried the following operations, did not solve the problem, or solved the problem but the efficiency is very poor, that is better than me. How to solve the same problem? How can they use different operations to solve the same problem more efficiently? What can I learn from it? What would I do if I did it again?


A question that naturally arises at this time is: Where do you meet these people who are better than yourself? How can I get their help and guidance? There are two ways: paid and free.

If you pay, for example, Zhihu's paid consultation. (Zhihu's product and operation and maintenance, if my answer helps you improve your business indicators, remember to include my other answers!) There are many people who are trying to pay for consulting such a thing, this industry is still not in China Mature, but you can try it if you can afford it. I do one-to-one career coaching, and the charge is $300 per hour (a rate of $5 per minute). If you need it, you can contact me privately.

 

After talking about paying, let’s talk about free. The most important thing here is to establish a relationship with someone better than you, so that the other person realizes that you are also creating value in the field that he cares about. Here is a simple step I provided:

  1. Pay attention to people who are better than you, see what they are talking about in their usual postings, and understand what they care about most.
  2. Participate in the interaction under the content he posted, and express your insights about his field. The most important thing is that your insights can create new value beyond his existing content.
  3. After continuing to interact with him, he may take the initiative to want to know you, otherwise you can take the initiative to send him a private message and ask that you want to know him. If you take the initiative, you'd better bring a valuable topic to start a private message conversation.

I can give you a very specific example. When I talked to a big guy, his first sentence in a private message was "Take up the courage and shameless wave. Can you give me a professional answer for this answer?" I feel that the quality of the answers he wrote is good, and it does provide value for the international students who have written the questions, so I did not hesitate to help his answer with a professional.

 

After you establish a relationship with someone who is better than you, give some patience and talk more. People are often willing to help you when you need it.

 

This concludes the article

 

Benefits from the editor

Today’s technology sharing is here. I recommend a book Java Concurrent Programming Art. If you need it, you can  click me to get it for free  . There are also some Java core knowledge points compiled by the editor to share with you. !

If you like the editor’s article, you can like it three times, and you can also use it for free.

 

Guess you like

Origin blog.csdn.net/SQY0809/article/details/109458928