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

推荐订阅源

T
Threatpost
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
G
GRAHAM CLULEY
S
Securelist
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
博客园 - 叶小钗
B
Blog RSS Feed
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
K
Kaspersky official blog
D
Docker
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
H
Help Net Security
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
美团技术团队
腾讯CDC

博客园 - 湘南和也

终于从梦中醒来 第一次动手做菜(炒菜片) 第一次动手做菜(切菜篇) web开发中让我郁闷不已的小失误 关于卸载windows service后再重新安装遇到的特殊问题 完成我的第一个windows service的开发 7天内两爬白云山 学习socket编程之一:用smtp协议发送邮件 无言随笔 心情不爽 实战服务器环境设置 感悟 我看盗版现象 黄山游记(三):登黄山 也许是被忽略的update语句 灵活使用DataView 黄山游记(二)初来乍到 黄山游记(一)预备篇 好久没更新了
程序编码应保持良好的规范(C#)
湘南和也 · 2005-07-07 · via 博客园 - 湘南和也

呵呵,这个简直是超级老生常谈了。但我还是希望能让更多的程序员能了解一些细节习惯对于程序阅读性的影响。而这个很大程度决定了程序的可移植性。

1。变量赋值之间注意保留空格。有些程序员往往不注意。
不好的:

好的:

点评:
单独一句还不觉得,当几十行在一起的时候,就够你头痛了。

2。for或者if等语句,注意保留大括号。
不好的:

if(i!=arrHidBrand.Count-1)
                        hidbrand
+=",";

好的:

其次:

if(i!=arrHidBrand.Count-1) hidbrand += ",";

点评:
当很多同类型的语句嵌套的时候,第一种写法就很容易混淆出错,第二种写法则清楚明白,第三种也相对容易理解。

3。尽量避免使用复杂的句式和语法,比如三元操作符等。下面举例说明。
不好的:

Body.txtHidBrand.Text=hidbrand==","?"":hidbrand;

好的:

点评:
相信大家看到第一种写法的时候都要想想才能理解过来吧。好的代码应该让人赏心悦目,我们的很多人都没有注意。

4。代码重复提取,减少重复代码。这个属于高的要求了,希望每个人写完后能review自己的代码,尽量精简自己的代码。