Summary of work efficiency issues

Source: Internet
Author: User

Today, I wrote a TCP duplex communication program, and the program was soon completed. However, during debugging, a simple problem plagued me for a long time, efficiency and methods are really important for our programmers.

Let me briefly talk about my problems:

This is a demo of duplex communication between the TCP server and the android client on Windows. The server and the client will soon be completed because of the complete set of examples that have been written before,

First, enable the server program, listen to the client connection, and save the Socket connected by the client to a dictionary. Then, the server uses the socket in the dictionary to issue commands to the client at a certain time; finally, the client prints the issued command.

However, during debugging, I found that as long as the server sends a message to the client using socket, the connection attribute of the socket in the dictionary becomes false, day! How can this happen. In the beginning, I thought there was something wrong with the server. I looked at the code and made breakpoint debugging... the result was still like this, which wasted a lot of time here.

Later, when the socket on the client is released (there are many possible reasons, such as an error), the connection attribute of the socket on the server is false!

It took a long time to view the client code and break the breakpoint and debug the Code. (The time slipped away in this unintentional debugging !), The results showed that the client could receive the Command issued by the server for the first time, but failed to receive the command for the second time. At that time, I did not think much about it, and ran debugging in a crazy place where I received it ...., finally, I found that, after the first time I received it, some variable marked as the number of bytes that had been received did not return to zero! (). It took so long for such a simple question. Really failed!

I have been a programmer for more than a year. How can I improve my work efficiency ?! We should just calm down and think about what the problem may be, what causes it, and do not blindly rely on running debugging. Use your mind to think about the whole process of the program, the right remedy can be obtained only when the problem occurs. Don't rush to run debugging, don't rely too much on computers, we have ideas.

The key is to practice more, think more, learn more, and be rigorous.

I have also googled some information on the Internet. I want to extract some information here. I hope it will be helpful to myself and to my friends who have seen this blog.

1. If you forget the history, you need to input it again.
2. Write unit tests to improve work efficiency

Imagine if a small code error occurs when you are writing a large network application, modifying it means rebuilding the entire program, re-configuring the data, and re-checking the features (this error may be hidden in depth ). Imagine that you may need to repeat similar things over and over again. Now, with the help of "unit detection", you can avoid repeating previous modifications/checks, which can save a lot of time.

3. Train your programming skills,

This is actually very easy. Check out other professionals. Cricket players use "Online Training" to improve their skills. Musicians improve their performance through practice. Singers also need to constantly improve through exercises. Surprisingly, most programmers do not practice. But you need to keep practicing.

Read some types of books such as objective Java and design patterns, and perform basic training every day. Find out some problems from the Euler program and solve them in your favorite computer language.

Editor's note: the Euler project, a knowledge detection website, regularly publishes questions and submits correct answers to discuss and learn different solutions to the questions.

Unlike normal projects, there is no time limit for these exercises. Therefore, make good use of your time to do things correctly. Through such exercises, your work efficiency will be greatly improved. This is obvious, isn't it?

4. Read the code and technical materials

Reading code is just as difficult as modifying/writing code. In today's open-source world, you can refer to a large number of high-quality code. Select your favorite development library and read it carefully to make full use of the resources. You may not be able to understand all the content quickly, but through continuous training, you will be able to differentiate the different modes used in them and use these patterns in your code.

In addition to viewing the code, you can also subscribe to blogs of excellent experts in the professional field to obtain the latest trend information.

5. Seriously consider it
Generally, it takes some inspiration to solve a difficult problem. If you are not familiar with that field, you should start from studying this field, learn from others' experiences, and gradually study and understand this field, and make some small attempts to see if you can deal with this field.

6. Do not repeat the same things and spend a little time every day to make every day more efficient.

7. The more concentrated the energy, the more careful the thinking

8. Use and improve the development library

Many programmers do not like to use development libraries. They would rather write their own code than use the development library. The main reasons are as follows:

A. They do not know the development library;

B. There is a lot of information in the development library that they don't need;

C. Compared with the development library, they are easier to master their own code;

Consider the following:

A. the development library has been strictly tested and has a wide coverage range, which can help you save a lot of time. If you have improved the development library, you can help many people.

B. But if you only improve your private code, there is no such impact.

C. Most importantly, other colleagues are also helping to supplement the development library information, which can help you indirectly.

All in all, unless the development library is too inconsistent with your requirements, you 'd better consider using the development library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.