Yes, Willie, I'm still tuning bug!.
Wei Tsai is a code of cleanliness, not the slightest flaw.
In refactoring a class (this class is the work of other children's shoes, I am so refactoring, is it annoying?) ), some bad naming changes, the use of the comments deleted, the improper judgment trimming, can be used as a function of local variables into the corresponding function, and so on.
Looking at the crisp code, I am happy to drink saliva.
After the code is submitted, take a walk.
When you come back, think of testing it. Although it is only to reconstruct some of the irrelevant areas, but the rules are still to abide by. (In fact, it is a violation, no test to submit the code itself will be punished!) But who makes Wei so confident? )
Compile...
Run...
I wipe, just also good reading card program, how to read the content??!
Carefully check my submission and find no modification affecting the reading card.
That's strange, so many simple changes really don't affect the big features.
or fallback code. New pull a branch down the code and fall back to the previous version.
Aye It's not good to use. Take a good look? Careful study of the next, the previous version is useful.
Or is it the result of my modification.
Very do not understand, with uncomfortable, slowly restore the code to troubleshoot. Experienced many times, still can't read out.
I thought it was interesting and I decided to find out what was going on.
When I think it's never possible, the miracle happens when you restore a local variable to a class member variable! It works!
It makes me so incredible.
Well, read the code carefully. Find a very long method, inside hidden a recursive call, resulting in a null return value!!!
Yes, that's the class member variable.
What's going on here? Let me write a pseudo-code description under:
Public classRecursive {//static String result; StaticString CallMe (intInput) {String result ="";//result = ""; if(Input = =1) {callyou (1); }Else if(Input = =2) {callyou (2); }Else if(Input = =3) {result ="3"; System. out. println ("input ==3:"+result);returnResult } System. out. println ("return:"+result);returnResult }Static voidCallyou (intInput) {CallMe (input+1); } Public Static void Main(string[] args) {String answer = CallMe (1); }}
Excuse me:
1, CallMe will return several times?
2, what is the value of answer?
Because the method is called three times, the corresponding return is three times.
The answer value here is "" instead of "3".
It's just too good!
Originally recursive invocation brought the cost of reading code, and in this method of return value with a recursive variant, which in the complex code is added to the infinite hidden trouble.
Wei Tsai said that today is in the pit.
The status quo of it fetish 45-I fell into a trap.