guides:programstyle:functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:programstyle:functions [2020/08/04 15:37] – [Function Length] wikiadmin | guides:programstyle:functions [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 57: | Line 57: | ||
===== Function Cohesion ===== | ===== Function Cohesion ===== | ||
- | ===== The main function | + | There are two aspects of function |
+ | - The code in a function should perform a single well-defined task. | ||
+ | - The code in a function should be at the same level of abstraction. | ||
+ | |||
+ | In the first case, this may be a simple or very complex task but it is a single task. | ||
+ | |||
+ | In the second case, the program should consist | ||
+ | |||
+ | ===== The main Function ===== | ||
+ | |||
+ | The main function for most advanced programs should read like an algorithm to solve the main problem. | ||
+ | |||
+ | A single line main function is not acceptable. | ||
+ | |||
+ | |||
+ | ===== An Example ====== | ||
guides/programstyle/functions.1596555427.txt.gz · Last modified: 2024/07/25 15:01 (external edit)