学习笔记之《Code Reading:The Open Source Perspective》Chapter one

本文探讨了阅读高质量代码的重要性,包括如何通过阅读代码提升个人技能、识别低质量代码的特征,并提供了实用的方法来提高阅读效率。此外,还介绍了在阅读过程中需要注意的事项及如何贡献改进。

Ø  Why to Read Code

Make it a habit to spend time reading high-quality code that others have written. Just as reading high-quality prose will enrich your vocabulary, trigger your imagination, and expand your mind, examining the innards of a well-designed software system will teach you new architectural patterns, data structures, coding methods, algorithms, style and documentation conventions, application programming interfaces (APIs), or even a new computer language. Reading high-quality code is also likely to raise your standards regarding the code you produce.

Ø  Signs of low quality code

l  An inconsistent coding style

l  A gratuitously complicated or unreadable structure

l  Obvious logical errors or omissions

l  Overuse of nonportable constructs

l  Lack of maintenance

Ø  Notice

Notice and appreciate the code's particular nonfunctional requirements that might give rise to a specific implementation style. Requirements for portability, time or space efficiency, readability, or even obfuscation can result in code with very peculiar characteristics.

Ø  How to read code

1.   Given a basic familiarity with programming and the underlying computer science concepts, you can in many cases use source code as a way to teach yourself the basics of the new environment.

2.   The next step involves actively changing the code to test your understanding. Again, begin with small changes and gradually increase their scope. Your active involvement with real code can quickly teach you the basics of the new environment.

3.   Once you think you have mastered them, consider investing some effort (and possibly some cash) to learn the environment in a more structured way. Read related books, documentation, or manual pages, or attend training courses; the two methods of learning complement each other.

Some tips:

1.   When you read code that falls in the above categories, keep in mind the specific nonfunctional requirements to see how your colleague satisfied them.

2.   If the code is valuable to you or your community, think about how you could improve it. This can involve using a better design or algorithm, documenting some code parts, adding functionality, or consider reinvesting your understanding of the code in improved documentation.

 

Andy编辑于2010-07-16   21:49:14

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值