Objective
I have a skill, that is to say "I" sounds particularly like "Lao Tzu".
When I was a little minions, I would tell the leader, "I!" Do not work overtime. "It sounds like," I don't work overtime! As At the end of the discovery, I really did not drag the work of the project to the need for overtime to complete, the "Lao Tzu" is slowly admitted! By the time I was in the lead, I said, "I won't let you work overtime!" "It doesn't sound like " I won't let you work overtime! "And then they really did not work overtime to finish the project beautifully, I believe they are willing to admit that I have" Lao Tzu's ability.
Ha ha! This is a little arrogant. Do it, don't say so! Low profile, low profile. But I can do anything without working overtime, it's true. In this series of articles I want to tell you a series of practical experience, after implementation will find: You can be delivered once! No more overtime! Have more time to accompany the wife and children! Have more time to accompany Brother brothers! There may be more things to do with your sister! ...... In short, the benefits abound.
This article tells the first principle-does it really need to be try-catch? Will not be updated periodically.
Is this really supposed to use Try-catch?
Think twice before you use Try-catch! In fact, the vast number of cases should not be used Try-cath. The behavior of the machine is very deterministic, especially the CPU, and its processing is a series of combinations with, or, not. Once saw an advertisement on the http://bbs.pfan.cn/, a programmer studies the result--the machine already has the intelligence! Why is it? The machine can give an indeterminate result-sometimes you use the operating system, software is very smooth and useful, sometimes as if a special trick. By! The bug of the program when artificial intelligence, is also drunk. Talent is more "owed", you let him enter the number, you can enter ABC; you let him enter ABC, he just entered the number. There are a bunch of less-beaten programmers behind all the machines that are under-beaten!
So in the development of flexible processing of the place only to deal with natural persons with the machine to interact with the place! Other places are able to agree on clarity as much as possible, rather than relying on exception handling and recovery mechanisms.
The agreement clearly explains the internal behavior of the program fully mastered, such code execution efficiency, good debugging. In other words, the fewer try catch in code, the more robust the program. Java has only introduced exception handling mechanisms for error handling, so there are two types of exceptions in Java checked and unchecked,unchecked are inherently errors, and a program that has been published in principle is not allowed to appear unchecked exceptions. C C + + C # and other languages introduced the Assert mechanism, which causes the program to encounter errors when the execution of the direct abort, this mechanism, the error can not be hidden. Can agree clear time as far as possible to agree clearly, is to not work overtime now Ah! Man! The agreement is clear, when writing code is not smooth, ah, do not need to write so much destruction structure of the Try-catch Ah! Some write code is like constipation, do not work overtime just blame it! Do not use Try-catch let the mistake hide, is to not work overtime later Ah! Man! The mistake hides, later out resembles "the artificial intelligence" the mistake to kill you! Cry Father Shout Niang, find can not find! Don't understand mistakes! The agreement is clear, including the exception is also taken into account, Microsoft's staff wrote a book seems to be called "How to write error-free code", which mentioned a lot of errors are in error handling inside. What an exception means--possibility and impossibility. You need to consider the exception where there is--io and someone else's code. IO good understanding, network communication, file reading and writing, database connection and so on. Other people's code is also very good understanding AH-you do not owe, do not mean that others do not owe AH. With regard to this principle, many articles that introduce specific practical methods are mentioned, and there is a summary of--assert () function usage. It is not acceptable to find many Java-only or Java-learning principles. It is easy to accept this principle from the Assembly, C, C + +. Don't take it it doesn't matter, don't come up and spray me! Before spraying, still think about it.
Practice of not working overtime (1)-Is this really supposed to be try-catch?