I have encountered many mistakes that I don't understand, and I am overwhelmed. I have summarized some reasons, which should be very important during development.
1. It cannot be assumed that it can run under excellent conditions. ProgramThis is done. Especially for network applications, when the network environment is very bad, it may be very different from the initial requirement, or it is not the same thing at all. Therefore, your application can only run in the LAN. It should be said that the programs that can run in the LAN are the least secure. I am really scared.
2. Do not give up writing logs or error records for fear of troubles. Some of the features were in urgent need some time ago, so we had a rush and made a demo. Who knows this demo is the one that made me the ghost cloud. The main reason is that the program has no output and no logs, that is, file transmission is performed in the background. The result is 100% failure. Finally, in order to find the error, you have to re-write the log and write the debugging output. Finally, small errors are found in the log. Therefore, if a function cannot be completed in a short time, do not do it. Definitely, you cannot write an unqualified demo to meet the requirements.
3. The try and catch structures must be reasonable. In many cases, to get exceptions or make programs run correctly, all errors are caught. The results are unpredictable, and sometimes errors may be more terrible than try. A simple example: in the thread, it will catch the abort exception, which should be terminated by the thread. After the result is caught, an error is handled without terminating it. The result can be imagined. Of course there are many more. Therefore, a good practice is to clearly catch the exception you want. If it is not clear, please throw an exception again after cleaning up the resources so that other parts of the application can handle it, or let the program to terminate the exception clearly know that there is an unknown exception here, and then proceed with further processing.
4. resource usage should be clearly allocated and displayed for release. One of the errors encountered a few days ago is that a deadlock occurs when multiple threads access the same file. The reason is that a thread does not safely release the file handle before it dies. The easy way to modify this error is to explicitly display the release file, which should be released immediately after the file is used, or released immediately after the exception occurs, instead, it cannot be released when the thread is terminated.
The above is a summary of the errors encountered in the past few weeks. Errors and modification errors take a lot of time, but errors are often a small problem. Write the program. Be careful.
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