. Net naming rules and Development conventions

Source: Internet
Author: User

The formation of a new team is a huge problem, especially for students who have just graduated, they need to strengthen their learning and training in this area. Last week, I explained the. NET Programming specification to our new colleagues. By the way, I also reviewed the programming specification. Because there are not many preparations in the early stage, and the company does not have such documents, write down the documents and keep them for future use. These are just some of the conventions used in the next years, it may be wrong or wrong. You are welcome to correct your criticism.

 

Naming rules:

There are three most common naming rules, most of which come from them. They are:

  • Hungarian method. This naming technique was proposed by Charles Simonyi, a competent Microsoft programmer, who was born in Hungary. It is named "Hungary naming method" and mainly used for window system programming.
  • Camel naming method: also called the camel naming method. The reason is that the name using this naming method looks as high and low as the camper's hump. Use this method when the first letter is lowercase, for example, string myaddress; is not public.
  • Pascal naming: Also called Pascal naming. Naming rules for uppercase letters. For example, string myaddress;

. Net naming rules:

In. NET programming, the combination of camel and Pascal naming method is generally used for naming.

Class

Pascal

Appdomain

Enumeration type

Pascal

Errorlevel

Enumerated Value

Pascal

FatalError

Event

Pascal

Valuechanged

Exception

Pascal

Webexception

Read-only static Fields

Pascal

Redvalue

Interface

Pascal

Idisposable

Method

Pascal

Tostring

Namespace

Pascal

System. Drawing

Parameters

Camel

Typename

Attribute

Pascal

Backcolor

 

Generally, you can write good-looking code by following the naming conventions above. Of course, during team development, you should also note that the public and protected method attributes are commented out. Code beautification is helpful for reading, in addition, you can see methods or other usage situations clearly between multiple members.

 

C # Document Layout

Generally, the copyright, developer, development date, and other information must be added to the C # file first, which can be implemented by registering the class template without the need to add or rewrite the file one by one.

/*************************************** ************************

* Developer: netsoul soldier
*
* Cache instance.
*
* Last modification: 2011-10-28
**************************************** *********************/
Namespace mynamespace
{
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;

Class myclass {}
}

Of course, you can write the referenced namespace before it, but I prefer to put it in it. I usually help developers of our team register a class template for them, so the classes added each time are basically like this. Another article about how to add a class can be viewed in my blog:

Vs2010 class template changes, adding copyright and other information

 

Naming Conventions for database Methods

For an instance, there are generally only four SQL statements: insert into, delete from, select from, and update set. I usually ask team members to use create, delete, get/load, and update. Of course, if both methods can have insert and update, you can also use createorupdate/save. The method name uses the verb-object Word format. If multiple sets use the plural form.

 

In the end, enumeration is also encouraged to replace the features of various numbers and other representations, and const constants are used to replace frequently-occurring strings, so that each place is not needed during modification. In addition, the use of enumeration provides better code readability. I haven't written a blog for a long time, and I don't know how to write it. I want to write something about it. Let's make a debut today. Thank you for your criticism and correction !!!

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.