C # Summary of language specifications

Source: Internet
Author: User

C # Language specifications-annotation specifications

A) File Header comment

[Rule 1-1] All files contain file headers, including file names, authors, creation times, and change records.

Rule 1-2: We recommend that you use. Net to write head comments.

B) Class and member comments

[Rule 2-1] The other method and class use the slash "//" to comment.

[Rule 2-2] The codes are annotated with "//" and "", and the problem should be explained as much as possible.

C # Language Specification-text specification

A) abbreviations and specifications

[Rule 1-1] identifiers are expected to be clearly understood and do not advocate the use of any abbreviations.

[Rule 1-2] string variables should start with "str" or "S" and be initialized using string. Empty.

Rule 1-3: A common object can start with "OBJ.

[Rule 1-4] The abbreviation can be customized. Generally, it consists of the first and last characters of a word. The meaning is intuitive.

[Rule 1-5] in general, do not let the abbreviation destroy the meaning of the identifier.

B) typographical

[Rule 2-1] each line of statements occupies at least one line. If the statement is too long (more than one screen), the statement is broken into two lines.

[Rule 2-2] groups similar content, such as fields, attributes, methods, and events, using the "# region -- # endregion" command.

Rule 2-3: Multiple program elements must be added with spaces before, after, or before and after the operators for peer-to-peer operations.

Rule 2-4: In principle, the number of source code lines for each method should be less than 200.

[Rule 2-5] The nesting level of a statement cannot exceed three layers.

[Rule 2-6] prevents the same code segment from appearing in multiple places.

C) Statement Structure

[Rule 3-1] if an exception structure is used, you must handle the exception. Generally, you must write a log file.

[Rule 3-2] branch statements should not use complex long conditions, but should encapsulate long conditions into methods.

[Rule 3-3] switch statement. Break must be followed by case.

[Rule 3-4] do not use the GOTO statement to redirect.

Rule 3-5: "magic number" is strictly prohibited in the line. constants of specific meanings must be defined as enumeration or constants.

[Rule 3-6] when operators of different types are mixed, brackets are used to give priority.

[Rule 3-7] complex operator combinations are not allowed.

[Rule 3-8] The block part of the loop and judgment statement is enclosed in curly brackets, even if there is only one statement.

[Rule 3-9] a default clause is always required in a switch statement. We recommend that you use assertions.

[Rule 3-10] each class and method provides a single function and does not design a class or method that is comprehensive in multiple purposes.

[Rule 3-11] It is strictly prohibited to use uninitialized variables. variables are usually initialized using constructor methods.

D) code indent

[Rule 4-1] A new line is required when you encounter braces.

[Rule 4-2] The parentheses line feed specification in Java is not allowed.

E) case

[Rule 5-1] do not create any elements with the same name but case sensitivity.

Rule 5-2 should be capitalized with only two characters.

[Rule 5-3] Do not put confusing numbers and characters together.

Rule 5-4: Use an English name identifier.

F) Duplicate name specification

Rule 6-1: Variable, class, attribute, and method names cannot be the same as system identifiers. (For system identifiers, see the appendix)

G) SQL coding Specification

[Rule 7-1] All SQL statements are capitalized.

[Rule 7-2] adds comments to complicated SQL statements to describe their functions.

Rules 7-3: Add spaces before and after the connector or, in, and, and =, <=,> =.

[Rule 7-4] Use clear columns instead of select *.

H) Software Architecture

Rule 8-1: Each table in the database corresponds to an object class/Data Transmission object (DTO ).

[Rule 8-2] The object class name uses the table name and can also contain the DTO suffix.

[Rule 8-3] The layer-3 architecture should be reasonably used and should not be applied.

[Rule 8-4] suffix is recommended for layer-3 Architecture elements:

Data transmission object xxxxdto

Dao factory xxxdaofactory

Dao interface ixxxxdao

Service Interface ixxxxservice

Database Implementation of Dao xxxxdaooracle/xxxxdaoinfomix

Business Logic xxxxmanager

I) System

[Rule 9-1] do not use the design mode or other code modes in China, because they are not popular.

[Rule 9-2] system input, resource operations (such as memory allocation, file and directory operations), network operations (such as communication and calling), inter-task operations (such as communications and CALLS) must be handled in case of errors, timeouts, or exceptions.

[Rule 9-3] The module compilation should have comprehensive testing considerations.

The question about the C # language specification is here, and I hope it will be useful to you.

[Edit recommendations]

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.