Find code Bad name _php tutorial in the project

Source: Internet
Author: User
Something that is often done and often thought of.

Obscure if condition

1) for | | The processing

The code above will take more time than the following code.

 Although reducing the number of lines of code is a good goal, minimizing the time required to understand the code is a better goal.

return value

The "$ret" above is an alibi for "I can't think of a name." Instead of using such empty names, pick a name that describes the value or purpose of the entity.

$alias declares that this variable is used to host aliases-The purpose of this variable is indicated. And it could help us find a flaw.

A good name should describe the purpose of the variable or the value it is carrying.

Temp variable

The $i here is "my temp variable", which is designed to automatically increase statistics and avoid duplication of statistical points. But the most important thing for this $i is not temporary variables. Using Charset_index to represent "subscript for my statistics" is more descriptive.

Loop iterator

I also found a bad taste in my JS code.

I variable name is very vague, so do not do so.

Names like I,j,iter and it are commonly used for indexing and looping iterators. Although the names are vague, everyone knows that they mean "I am an iterator". You actually use these names to express other meanings, which can be confusing. So don't do this.

If you have to use i,j,it such a vague name, then you have a good reason to convince yourself.

Summarize

In the process of coding, it takes a few seconds to come up with a good name, and you will find that our "naming ability" is quickly lifted up.

I usually first think of the Chinese name, if I can not think of the corresponding English name, I will use the translation tool to put the thought of Chinese paste up, and then to crop the name of the variable or function names.

Give me a nice name that I've seen recently.

http://www.bkjia.com/PHPjc/325648.html www.bkjia.com true http://www.bkjia.com/PHPjc/325648.html techarticle often-done and often-wanted things obscure if condition 1) for | | The processing of the above code is more time-aware than the following code, although reducing the number of lines of code is a good goal, but ...

  • 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.