Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the nine coding specifications that ASP.NET should follow?

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you what are the nine coding norms that ASP.NET should abide by. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

After writing the program code for such a long time, I found that many people's code is very irregular. Especially when several people work together to develop a project, some people write class names, variable names, methods and so on that people can't understand them at all, so that the whole project may not be able to be combined. I think my code is already very good, at least I can see the meaning of the name. However, after reading these 9 items, I think I have to study further.

1. The name of the local variable should be meaningful, try to use the corresponding English name, such as "user name" variable, do not use aa bb cc and so on, but use userName.

two。 Do not use single-letter variables such as I, n, x, etc. Instead, use index, temp, and so on. Exceptions to variables used for loop iterations.

3. You should use Pascal naming to name method names, attribute names, class names, and namespaces, and methods are generally named as verb-object phrases, such as

◆ ShowDialog ()

◆ CreateFile ()

◆ GetPath ()

4. Use the Camel naming method to name local variables and method parameters.

The comprehensive examples of the above are as follows

Public class Neeke {public Neeke () {} private string neekeName; public string NeekeName {get {return neekeName;} set {neekeName = value;} public void CallMe () {System.Console.WriteLine ("Hello Neeke!");}}

5. Only the Hungarian naming method is used to name WinForm and Web spaces, and default naming such as textbox1, gridview1, and so on is prohibited.

6. Interface names are prefixed with uppercase and lowercase I, such as INeeke, to visually distinguish between interfaces and classes.

7. Use the hierarchical structure of namespaces to organize classes and interfaces.

Correct:

Using Www.Ineeke.Cn;namespace Ineeke.Cn {...}

Error:

Using WwwIneekeCn;namespace IneekeCn {...}

8. All code must be adequately annotated, with a comment volume of more than 15%. The contents that need to be commented include the following.

1) key statements (such as key variable declarations, condition judgments, etc.).

2) the documentation comments before the class name (comments that begin with /) include a simple functional description of the class, how to use it, and so on.

3) the method with complex parameter list.

9. Code indentation uses the Tab key, not the spacebar.

These are the nine coding specifications that ASP.NET should follow, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report