search

Home  >  Q&A  >  body text

In programming, what are some good habits worth sticking to from the beginning?

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老师2178 days ago2927

reply all(7)I'll reply

  • 合肥php培训

    合肥php培训2019-02-23 13:29:06

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

    reply
    5
  • 不言

    不言2019-02-13 15:08:44

    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.

    reply
    3
  • 云罗郡主

    云罗郡主2019-02-13 15:00:35

    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

    reply
    1
  • 清浅

    清浅2019-02-13 14:59:50

    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

    reply
    0
  • PHPz

    PHPz2019-02-13 14:17:56

    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.

    reply
    2
  • 藏色散人

    藏色散人2019-02-13 13:38:42

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

    reply
    0
  • Cancelreply