Read the first four chapters of the Code of cleanliness and the untidy code I've seen warning

Source: Internet
Author: User

1.----A well-behaved attitude at all.

2. Naming----Meaningful, canonical, searchable names, using names derived from the problem domain, at least avoid misleading.

3. Class name----noun or noun phrase.

4. The method----should be a verb or a verb phrase.

5. Pun----It is best not to use this, who knows add is added or additive?

6. Function----short, the deepest impression is that a function only do one thing, even if we need to use Try-catch, but also to separate into a method, and the first word of this method should be try.

7. Note----Code is the highest state of course, when we want to write comments to better express the program, think there is no better way to change. If a comment is required, then the comment must be.

Concise, and annotations also need to be maintained, and perhaps as the code evolves, the old annotations become meaningless.

---------------------------The above contents are subject to further additions---------------------------------------------

Counter example: The disgusting code I've seen, warning

1. When dealing with similar logic and functions, complete copying of the code, no personal thoughts, even methods, objects, variable names are not modified, even the copied comments are not modified.

2. A method dozens of lines or more--a screen can not fit, take a part of the JQ asynchronous code, asynchronous is a thing, get asynchronous need to pass the argument is one thing, asynchronous success or error callback implementation is another thing, callback method of more operations or a thing, All sorts of things to write down, still can see?

3. Some people who think of Daniel as fulfilling certain complex functional requirements are not interested in perfecting some of the calibration and detail work left to interns, but cleanliness is not flattering. The problem is that other people are not convenient to change, and the other is that it lets you perfect the details of the time, but also re-read the code two times, I think this will not improve the efficiency of it.

4. A seven or eight-parameter method that requires the passed parameters to not leave a comment? Not only is it difficult to modify, it also makes people confused when calling a method.

5. A business basically does not need to process logic, can be convenient to operate the database directly in the logical layer? Incredible!

6. When using ASPX, the CS file does not have a single line of code, for the overall beauty of the project, but to persist in using ASPX? Is it really beautiful?

7. Dozens of or even hundreds of pages, placed in the same folder better or slightly sub-class good!

8. A ashx that is responsible for adding and deleting changes, can be named Addadmin? Aren't we manageadmin?

Read the first four chapters of the code clean-up and the untidy code I've seen warning

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.