Control-Unusual Structures
来源:互联网 发布:阿里云服务器磁盘分区 编辑:程序博客网 时间:2024/05/01 18:10
Multiple Returns from a Routine
1. Use a return when it enhances readability.
2. Use guard clauses(early returns or exits) to simplify complex error processing.
3. Minimize the number of returns in each routine.
Recursion
1. Make sure the recursion stops.
2. Use safety counters to prevent infinite recursion.
3. Limit recursion to one routine.
4. Keep an eye on the stack.
5. Don't use recursion for factorials or fibonacci numbers.
Some possible rewrite strategies for goto
1. Rewrite with nested if statements.
2. Rewrite with a status variable.
3. Rewrite with try-finally.
Guidelines for using gotos
1. Use gotos to emulate structred control constructs in languages that don't support them directly.
2. Don't use the goto when an equivalent built-in construct is avaiable.
3. measure the performance of any goto used to improve efficiency.
4. Limit yourself to one goto label per routine unless you're emulating structured constructs.
5. Limit yourselft to gotos that go forward, not backward, unless you're emulating structured constructs.
6. Make sure all goto labels are used.
7. Make sure a goto doesn't create unreachable code.
- Control-Unusual Structures
- 代码大全学习-20-不常见的控制结构(Unusual Control Structures)
- 1.4. Control Structures
- R Programming week2 Control Structures
- 【Scala】Scala之Control Structures
- CHAPTER 24 VIRTUAL-MACHINE CONTROL STRUCTURES
- c++教程(七:Control Structures)
- 四、控制结构和函数Control Structures and Functions
- Scala Cookbook读书笔记 Chapter 3.Control Structures 第一部分
- Scala Cookbook读书笔记 Chapter 3.Control Structures 第二部分
- Unusual Product
- 《Code Reading:The Open Source Perspective》Chapter two之Control Structures Revisited
- Unusual Data Types
- Unusual memory bit patterns
- Trying Unusual Foods
- Unusual Memory Management Situations
- Unusual Product--CF238C
- Unusual Product(codeforces)
- 难得加班
- JAVA编写的日历
- 请教:在java中如何实现线程的函数互斥调用,用synchronized好像实现不了
- sql有关日期的实现
- IPMP讲座
- Control-Unusual Structures
- 男友总是玩游戏,怎么办?
- 改改--CSDN的文档与Blog的图片地址
- 一墙之隔
- 【★☆精典☆问题☆★】装完vs 6.0(vb,vc,犹其是vj++)后看不了real格式的在线电影了,郁闷
- 一日之记(ACM+聊天+明天计划)
- 在宿舍混了一天
- 使用存储过程封装应用逻辑的优缺点(转)
- 尝试用C++封装Socket库