Ting Feng left -ARTS- week 9 (2019/06 / 02-2019 / 06/08)

Algorithm

This week's algorithm One problem is PLUS ( https://leetcode.com/problems/plus-one/ ).

public int[] plusOne(int[] digits) {
        int i = digits.length - 1;
        while (i >= 0) {
            if (digits[i] == 9) {
                if (i > 0) {
                    digits[i] = 0;
                    i--;
                } else {
                    int[] target = new int[digits.length + 1];
                    target[0] = 1;
                    target[1] = 0;
                    for (int j = 1; j < digits.length; j++) {
                        target[j + 1] = digits[j];
                    }

                    digits = target;
                    break;
                }
            } else {
                digits[i]++;
                break;
            }
        }

        return digits;
}

Reading

This week's article is read "Check Your Code First before Looking to Blame Others" (https://97-things-every-x-should-know.gitbooks.io/97-things-every-programmer-should-know/ content / en / thing_09 /). The title of this article can be translated into check their code before blaming others, which most programmers, or that most people subconsciously action, code running problems, certainly written by someone else bug caused. These system-level software compiler, interpreter, operating system, database, memory, etc. have bug, a problem probability is very low, at least more than the number of times we doubt much less. When the program is out of the question, we should not take this time to focus on the above, we can isolate the problem, pay more testing, inspection and calling conventions shared libraries, and others to discuss other ways to debug problems. When someone raised a question can not be reproducible over, we can go to him and see how he is then operating out of the question, we did not think possible mode of operation.

Multithreading is another bug source, debug and unit testing is difficult to find these problems.

Tip

In Java, abnormal detrimental to performance. An exception is thrown first to create a new object, Throwable constructor function call interface local synchronization method named fillInStackTrace () is, fillInStackTrace () method to check the stack to collect information call tracking. As long as there is an exception is thrown, Java virtual machine must adjust the call stack, because a new object is created in the process. An exception can only be used for error handling, it should not be used to control program flow. 

Share

Spring AOP Overview ( https://www.cnblogs.com/minguo/p/10994322.html

Guess you like

Origin www.cnblogs.com/minguo/p/10991057.html