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

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
Vercel News
Vercel News
G
Google Developers Blog
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
F
Fortinet All Blogs
博客园_首页
S
Secure Thoughts
GbyAI
GbyAI
S
Security Affairs
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Archives - TechRepublic
Security Archives - TechRepublic
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Heimdal Security Blog
A
About on SuperTechFans
P
Proofpoint News Feed
H
Help Net Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
博客园 - 叶小钗
A
Arctic Wolf
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
人人都是产品经理
人人都是产品经理
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
Security Latest
Security Latest
The Hacker News
The Hacker News
T
Tor Project blog
O
OpenAI News
博客园 - 三生石上(FineUI控件)
PCI Perspectives
PCI Perspectives
量子位
大猫的无限游戏
大猫的无限游戏
Stack Overflow Blog
Stack Overflow 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)  评论()    收藏  举报