惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 许文

Sql server一些常见性能问题的总结 ASP.NET 开发规范 第八章 其它 ASP.NET 开发规范 第七章 控件命名 ASP.NET 开发规范 第六章 语句 - 许文 ASP.NET 开发规范 第五章 命名 ASP.NET 开发规范 第三章 注释 ASP.NET 开发规范 第二章 代码外观 ASP.NET 开发规范 第一章 概述 ASP.NET 开发规范(目录) 多个子站点共用同一个Cookies验证 好久没有更新了,上传一个网站上通用的验证效果的函数吧。 信息系统集成项目管理的认识和体会 人月神话:软件界面交互和易用性改进总结 HotHeart写的Ajax类使用实例 ajax类使用过程出现的问题请教. 使用Nielsen的十条准则做WEB的启发式评估 写了一个Ajax的验证用户注册的函数, FileSystem对象常用的文件操作函数有哪些(转载) 您喜欢哪一种变量命名的规则
ASP.NET 开发规范 第四章 声明
许文 · 2007-08-24 · via 博客园 - 许文

第四章 申明

4.1       每行声明数

一行只建议作一个声明,并按字母顺序排列

          int level;   //推荐

          int size;    //推荐

          int x, y;    //不推荐

4.2       初始化

      建议在变量声明时就对其做初始化。    

4.3       位置

      变量建议置于块的开始处,不要总是在第一次使用它们的地方做声明。

         void MyMethod()

          {

              int int1 = 0;         // beginning of method block

if (condition)

{

                  int int2 = 0;     // beginning of "if" block

                  ...

              }

          }

        不过也有一个例外        

                for (int i = 0; i < maxLoops; i++)

                {

                    ...

                }

        应避免不同层次间的变量重名

            int count;

            ...

void MyMethod()

{

                if (condition)

                {

                    int count = 0;     // 避免

                     ...

                 }

                 ...

}

4.4       类和接口的声明

      1 在方法名与其后的左括号间没有任何空格。

      2 左花括号 “{” 出现在声明的下行并与之对齐,单独成行。

      3 方法间用一个空行隔开。    

4.5       字段的声明

不要使用是 public protected 的实例字段。如果避免将字段直接公开给开发人员可以更轻松地对类进行版本控制原因是在维护二进制兼容性时字段不能被更改为属性。考虑为字段提供 get 和set 属性访问器,而不是使它们成为公共的。 get 和 set 属性访问器中可执行代码的存在使得可以进行后续改进,如在使用属性或者得到属性更改通知时根据需要创建对象。下面的代码示例阐释带有get 和 set 属性访问器的私有实例字段的正确使用。 示例:

            public class Control: Component

            {

               private int handle;

               public  int Handle

               {

                  get

                  {

                     return handle;

                  }

               }

}