McConnell_2004_CH07_High_Quality_Routines Flashcards
1
Q
- What are some other words which mean the same as ‘routine’?
A
A routine is an individual method or procedure invocable for a single purpose. Examples include a function in C++, a method in Java, a function or sub procedure in Microsoft Visual Basic. For some uses, macros in C and C++ can also be thought of as routines.You can apply many of the techniques for creating a high-quality routine to these variants.
2
Q
- List 10 good reasons for creating a routine?
A
- Reduce Complexity
- Introduce an intermediate, understandable abstraction
- Avoid duplicate code
- Support subclassing
- Hide Sequences
- Hide pointer operations
- Improve portability
- Simplify complicated boolean tests.
- Improve performance
- To ensure all routines are small?
3
Q
- What does ‘cohesion’ mean when used a heuristic for designing a routine? p168
A
For routines, cohesion refers to how closely the operations in a routine are related.
4
Q
- What are bad kinds of cohesion for a routine?
A
- Sequential Cohesion
- Communicational cohesion
- Temporal Cohesion
5
Q
- State guidelines for creating a good routine name?
A
(Page 171 to 172)
6
Q
- How long should a routine be?
A
(Page 173 to 174)
7
Q
- What is one of the most error prone areas of a programme
A
A study at IBM found that the most error-prone routines where those that were larger than 500 Lines of code. Beyond 500 lines, the error rate tended to be proportional to the size of the routine.