|
|
|
###### [Home](home) / [Digitec Coding Practices](coding-practices) / [Global Coding Standards](global-coding-standards) / Smells and Heuristics - Functions
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
[:arrow_left: Environment](smells-and-heuristics-environment) | [General :arrow_right: ](smells-and-heuristics-general)
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
|
|
|
|
|
|
|
|
#### F1: Too Many Arguments
|
|
|
|
|
|
|
|
Functions should have a small number of arguments. No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice. (See "Function Arguments" on page 40.)
|
|
|
|
|
|
|
|
#### F2: OutputArguments
|
|
|
|
|
|
|
|
Output arguments are counterintuitive. Readers expect arguments to be inputs, not out- puts. If your function must change the state of something, have it change the state of the object it is called on. (See "Output Arguments" on page 45.)
|
|
|
|
|
|
|
|
#### F3: Flag Arguments
|
|
|
|
|
|
|
|
Boolean arguments loudly declare that the function does more than one thing. They are
|
|
|
|
confusing and should be eliminated. (See "Flag Arguments" on page 41.)
|
|
|
|
|
|
|
|
#### F4: Dead Function
|
|
|
|
|
|
|
|
Methods that are never called should be discarded. Keeping dead code around is wasteful. Don't be afraid to delete the function. Remember, your source code control system still remembers it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
[:arrow_left: Environment](smells-and-heuristics-environment) | [General :arrow_right: ](smells-and-heuristics-general) |
|
|
|
\ No newline at end of file |