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

推荐订阅源

Vercel News
Vercel News
SecWiki News
SecWiki News
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
腾讯CDC
Scott Helme
Scott Helme
I
InfoQ
Cyberwarzone
Cyberwarzone
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Latest
Security Latest
The Register - Security
The Register - Security
Project Zero
Project Zero
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
C
Cisco Blogs
L
LINUX DO - 热门话题
P
Privacy International News Feed
IT之家
IT之家
U
Unit 42
P
Privacy & Cybersecurity Law Blog
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Palo Alto Networks Blog
F
Full Disclosure
宝玉的分享
宝玉的分享
Simon Willison's Weblog
Simon Willison's Weblog
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
PCI Perspectives
PCI Perspectives
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog

博客园 - Arthur_wuancheng(大步牛)

练手之作:易元威客任务发布系统(2) 练手之作:易元威客任务发布系统(1) 人生一世 草木一秋 如何进行高效的项目管理?(转) 项目管理的一点总结 极限编程法一点思考 WEB Service 下实现大数据量的传输 (转) 项目经验(转) Atlas 学习笔记: ajax 改进 by Atlas ajax for .net in vs2003 like gmail ^_^ 存储过程分页,以及动态sql(Sql server) C# 2.0 New Feature(1) WebService Enhancements 2.0 Learning Note ref type & out type Duwamish架构分析篇 (转) 也谈代码规范 (转) 如何用正确的方法来写出质量好的软件的75条体会 [转] How to Write to Database by EnterPriseLibrary2005 Logging Application Block(项目心得) 自己正在做电信的互联星空项目,里面用到的xml
程序编码应保持良好的规范(C#)(转)
Arthur_wuancheng(大步牛) · 2005-07-08 · via 博客园 - Arthur_wuancheng(大步牛)

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

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

好的:

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

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

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

好的:

其次:

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

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

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

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

好的:

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

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

posted on 2005-07-08 11:51  Arthur_wuancheng(大步牛)  阅读(452)  评论()    收藏  举报