CleanCode code clean training Summary (2015), holiday schedule

Source: Internet
Author: User
Tags try catch

CleanCode code clean training Summary (2015), holiday schedule

The four-day CleanCode training is very short, and it is difficult to grasp some knowledge accurately, but it gives me a new understanding and inspiration for the Code; I have read books such as design patterns and refactoring before, and I have some feelings after reading them. I still cannot use them in code writing, in fact, reconstruction can be performed at all times and long-lived, whether the variables are used in a single way, the name of a function, an if statement expression, repeated code, single function responsibilities, short and easy to understand functions, and a single abstraction layer;

The Code previously written is so bad that it never re-organizes the code structure when you modify the code. The written code is to pay attention to the details when writing the code. How can we write the code well? This is a question worth thinking about as a programmer. The Code cannot be changed after it is designed. It should be changed in future demands and re-designed continuously, which is more conducive to future expansion.

Refactoring is to modify the code without changing the external behavior of the Code to improve the internal structure of the Code Program, improve its comprehensibility, and reduce its modification costs. Essentially, refactoring is to improve its design after the code is written.

10 functions 1
1. Each variable is only used for a single purpose
2. Each line of code only expresses one thing
3. Only one thing in a loop
4. Single Abstraction Level Principle
5. The code is organized to do only one thing at a time.
6. There is only one reason for changes in the function body (motivation)
7. The function should abide by a single responsibility
8. The complexity of function circles should be less than 10.
9. The first principle of the function is that it must be short.
10. When writing a function, you must be one-minded, focused, and modest.

Programming 3 values
Communication -- cherish the importance of communicating with others
Simple -- Remove extra complexity
Flexibility-keep open and respond to changes

Circle complexity of computing programs
1. Start from 1 and go through the program
2. Once the following keywords are met, or other similar words plus 1 (if/for/while/and/or)
3. Add 1 to each case in the case statement.
4. Ternary operator? B: c plus 1
5. Add 1 to the try catch statement.

Other types of complexity measurement methods
1. Number of lines of code
2. Number of function parameters
3. Number of calls to other functions, objects, and packages
4. Number of operators per line
5. Number of statements to be transferred (goto/break/continue/throw)
6. Number of nested layers in the control structure
7. Number of variables, function variables
8. Number of lines of code (SPAN) between successive references of the same variable)
9. Number of lines of code for variable survival

Tame deep nesting Methods
1. Use the Wei statement
2. Simplify nested if statements by checking a part of the condition
3. Use the break block to simplify nested if
4. Convert nested if statements into a group of if-then-else statements
5. Convert nested if statements into case statements
6. Extract the deep nested code and place it in a separate subroutine.

Software quality can be divided into internal quality (Code architecture design) and external quality (software use process stability) famous iceberg Model
Four "modernization" of Internal Quality Management"
1. quantifiable ---- measurable
2. Tool-based: visualized and transparent, and tool-based detection (sourcemonitor can be used in Java)
3. Automation ----
4. Optimization-Continuous Improvement

Criteria for checking whether the code is corrupted
1. Standard Format
2. Name
3. Class and Function Name Length
4. Comments
5. Repetition
6. conditional expressions
7. Lap complexity
8. Function Parameters
9. number of variables in the function

Clean Code method for Reference
1. Only one thing in a loop
In general, the number of cycles is not very large, and the efficiency is not very obvious. try to separate them as much as possible, and the structure looks clear.
2. When using do/while, you must note that the execution is determined by the subsequent conditions.
3. The single exit of a function is not that important. If the readability is enhanced, return is used.

Download references

Http://pan.baidu.com/s/1gdd8YKr

Programming is an attitude, programming is a skill, and programming is a habit
Be a programmer with exercises, bottom lines

Related Article

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.