LTP:Crafting quality code
来源:互联网 发布:炉石淘宝买卡包安全吗 编辑:程序博客网 时间:2024/04/28 11:23
注:本文出自Coursera上的一门名叫“打造高质量代码”的网络课程的授课老师,是多伦多大学的CS教授,以下是他对构建代码的建议:
Paul Gries, the Senior Lecturer in the Department of Computer Science at the University of Toronto suggested some good habits in crafting quality code:
Plan before you type. One of my favourite quotes, from Greg Wilson (although I don't know if it's his), is "Sometimes and hour of thought can save you a week of hard work."
Make sure you understand the problem you're trying to solve before you try to solve it.
If you don't know how to write a function to do a task, do it by hand and think hard about what you're doing.
Test your code. You don't have to write all the tests first, but write at least a couple tests before you write a function. You do this in order to make sure you understand what the function is supposed to do.
If some code is broken, it's faster to figure out exactly what went wrong than it is to try things randomly until it works.
Top-down design has you write high-level sentences describing what you want to do. These usually make excellent comments.
Once you figure out something --- anything! --- make a note so that you don't have to figure it out again. Comments are usually the easiest way to do this.
The structure of your data is vital. Document it.
Bigger issues:
- Learn about version control. git is the current crowd favourite:
http://git-scm.com/
Watch video tutorials, try out git, learn the ideas behind every version control system. Every company uses version control of some kind; options include git, perforce, subversion, and many more. (We teach version control at the beginning of second year here at the UofT, and it's beyong the scope of LTP2, but it's really, really important, especially when working with other programmers.)
- If you know c-based programming languages (C, C++, Python, Ruby, Java, most others), take the time to learn a weird one. Haskell, Scheme, and Lisp are all excellent choices. Gregor Kiczales from UBC is running a Coursera course on Scheme, and I'm looking forward to following it myself:
- LTP:Crafting quality code
- quality for code
- Agile Java(TM) : Crafting Code with Test-Driven Development
- What’s high quality code?
- The JavaScript Code Quality Tool
- LTP
- Comments and the Quality of Code
- Code Quality: The Open Source Perspective
- 【收藏】An advent of unconditional quality code
- Code Complete ----- (Note2 Creating High-Quality Code)
- Quality
- WebGoat学习笔记(三)——Code Quality
- [Code Complete] CH7 High-Quality Routines高质量子程序
- the thinker of code complete -- High-Quality Routines
- [Python] Do your unit test to ensure code's quality
- How to improve quality and syntax of your Android code
- WebGoat实验之Code Quality(代码质量)- 2016.01.08
- Teaching course1 : How to improve your code quality
- oracle-- COUNT 函数的用法
- 黑马程序员_交通灯管理系统
- 【Android开发学习45】使用google语音识别引擎(Google Speech API)<一>
- UVaOJ103 - Stacking Boxes
- java.io.File类各种文件操作
- LTP:Crafting quality code
- 存储过程的使用
- UVaOJ10405 - Longest Common Subsequence
- 统计学生人数和成绩(静态)
- POJ-1258-Agri-Net
- CodeForces 298A Snow Footprints
- C语言中用柔性数组实现斐波那契数列
- ogre开发环境快速搭建(成功率100%)
- cookie 和session 的区别详解