programing c: styles
来源:互联网 发布:软件介绍ppt模板 编辑:程序博客网 时间:2024/04/30 00:38
Good programming style first;
Ideally, a program serves two purposes:
1. it presents the computer with a set of instructions;
2. it provides the programmer with a clear, easy-to-read description of what the program does.
Example:
One of the best ways to organize thoughts: write them down in a language that is clear and easy to understand.
Good programming styles comes from experience and practice.
Only one rule exists: make your program as clear, concise, and simple as possible.
At the beginning of the program is a comment block that contains information about the program:
Heading: contains the name of the program and a short description of what the program does;
Author: take credit for it, also for future modification help
Purpose: Why did you write this program? What does it do?
Usage: a short explanation of how to run the program.
References: reference the original author of any work you copied
File formats: list the files that your program reads or write and a short description of their formats
Restrictions: list any limits or restrictions that apply to the program
Revision history: contains a list indicationg who modified the program, and when and what changes were made
Error handling: if the program detects an error, describe what the program does with it
Notes: include special comments or other information that has not already covered
Declare variable:
1. Avoid abbreviations;
2. add a comment;
so that, in effect, a mini-dictionary was created. It's easy to look up the meaning of a name.
Do not be clever. Clever kills. Clever makes for unreadable and unmaintainable programs.
Programs, by their nature, are extremely complex. Anything that you can do to cut down on this complexity will make your programs better.
Identation and Code Format:
adapt to the one you feel most comfortable with
Clarity:
Simplicity:
some general rules of thumb:
1. a single function should not be longer than two or three pages.
2. avoid complex logic like multiply nested ifs.
3. long statements should be avoided.
4. make your program as simple and easy to understand as possible, even if break some rules.
A progrAm should be concise and easy to read. It must serve as a set of computer instructions, but also as a reference work describing the algorithms and data used inside it. Everything should be documented with comments. Comments serve two purposes. First, they tell the programmer to follow the code, and second, they help the programmer remember what he did.
Ideally, a program serves two purposes:
1. it presents the computer with a set of instructions;
2. it provides the programmer with a clear, easy-to-read description of what the program does.
Example:
/******************************************************** * hello -- program to print out "Hello World". * * Not an especially earth-shattering program. * * * * Author: Steve Oualline. * * * * Purpose: Demonstration of a simple program. * * * * Usage: * * Runs the program and the message appears. *********************************************************/#include <stdio.h>int main(){ /* Tell the world hello */ printf("Hello World\n"); return (0);}
One of the best ways to organize thoughts: write them down in a language that is clear and easy to understand.
Good programming styles comes from experience and practice.
Only one rule exists: make your program as clear, concise, and simple as possible.
At the beginning of the program is a comment block that contains information about the program:
Heading: contains the name of the program and a short description of what the program does;
Author: take credit for it, also for future modification help
Purpose: Why did you write this program? What does it do?
Usage: a short explanation of how to run the program.
References: reference the original author of any work you copied
File formats: list the files that your program reads or write and a short description of their formats
Restrictions: list any limits or restrictions that apply to the program
Revision history: contains a list indicationg who modified the program, and when and what changes were made
Error handling: if the program detects an error, describe what the program does with it
Notes: include special comments or other information that has not already covered
Declare variable:
1. Avoid abbreviations;
2. add a comment;
so that, in effect, a mini-dictionary was created. It's easy to look up the meaning of a name.
Do not be clever. Clever kills. Clever makes for unreadable and unmaintainable programs.
Programs, by their nature, are extremely complex. Anything that you can do to cut down on this complexity will make your programs better.
Identation and Code Format:
adapt to the one you feel most comfortable with
Clarity:
Simplicity:
some general rules of thumb:
1. a single function should not be longer than two or three pages.
2. avoid complex logic like multiply nested ifs.
3. long statements should be avoided.
4. make your program as simple and easy to understand as possible, even if break some rules.
A progrAm should be concise and easy to read. It must serve as a set of computer instructions, but also as a reference work describing the algorithms and data used inside it. Everything should be documented with comments. Comments serve two purposes. First, they tell the programmer to follow the code, and second, they help the programmer remember what he did.
0 0
- programing c: styles
- C programing
- OO Programing in C
- C Programing Lanuage Notes
- OO Programing in C (1)
- OO Programing in C (2)
- OO Programing in C (3)
- The C programing language 第一章
- The c programing languag chap8
- styles
- styles
- Styles
- Expert C Programing—阅读笔记一
- Expert C Programing阅读笔记二
- The C programing language K&R 笔记
- the c programing language 练习1-17
- The C programing language chapter 6 : struct
- Day 1 :start C Language Programing course
- spring使用注解方式该如何在框架外获取注入?
- ubuntu永久修改主机名
- 旺旺老师JavaSE基础第一章(04)HelloWorld
- Websphere Application Server JVM通用参数对文本文件汉字编码的影响
- 图的表示
- programing c: styles
- DialogInterface.OnClickListener和View.OnClickListener
- 不重启关闭selinux同时重启也保证selinux不启动
- hdu1217
- oracle 创建视图用 with check option 子句详解
- 使用CGI c语言 获取form表单的数据
- 合并两个有序数组
- oracle数据库时间问题的一个疑问
- 应用Buildbot实施c++持续集成