In programming, what are some good habits worth sticking to from the beginning?
z老师
z老师 2019-02-13 13:14:31
0
7
2820

In actual programming, what good habits are worth learning and persisting from the beginning?

Standardize your own code, have less personal style, and add necessary comments

This is the principle that I have always adhered to during the coding process.

What good habits do you have during the coding process? Welcome to share and leave messages!


z老师
z老师

学习是最好的投资!

reply all(6)

Tens of millions of lines of code, the first line of comments, the naming is not standardized, my colleagues cried after two lines

不言

1. Camel hump

Camel hump is divided into small hump and large hump;

a): small hump: the first letter of the first word is lowercase, and the first letter of the second word is lowercase. The letters are capitalized, such as userName

b): Camel case: the first letter of each word is capitalized, such as UserName

2, naming

Shorter words can The vowels are removed to form an abbreviation, and longer words can be represented by the first few characters of the word. Private methods and properties should start with an underscore "_", and the words used when naming should try to use the English words they play a role in.

3. Indentation

Appropriate indentation can make the code structure clearer. Generally, a tab, 4 spaces or 2 spaces are used for indentation.

4. Space

Under normal circumstances, a space will be added before the "{", "}", "+", and "=" symbols. No space will be added when calling the method. Define When using anonymous functions, add a space.

5. Comments

When modifying other people's code, indicate the time, name and reason before and after the commented-out content. When adding new functions, indicate the time, name and general function. Increase readability and maintainability.

云罗郡主

If you encounter something you don’t understand, check the official manual first. Most of the official manuals may be in English. Just use a translation tool to translate it carefully and try to understand it yourself

清浅

In the process of writing code, you must pay attention to the development of good habits. For example, when naming, you should make clear the difference between big hump and small hump
And try to use meaningful and simple word naming
When writing code, you should also pay attention to indentation, spaces and comments to enhance the readability of the code. and maintainability

PHPzhong

Recommend a course document: "PHP Development Coding Specifications" http://www.php.cn/course/982.html
The document contains detailed PHP code specifications, PHP annotation specifications, etc. The PHP coding specification is mainly to better improve the work efficiency of PHP developers, ensure the effectiveness and rationality of development, and improve the readability and reusability of program code. The value of this specification is that we all follow this Coding style.

藏色散人

Standardize the code, take notes frequently, learn more and practice more!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template