11
Functions
A function is a named block of source code that typically performs a specific task. The task provides the source code within the function cohesion. The return value is the result of the task. In addition, functions can cause side effects, such as setting an out parameter, writing to a file, or inserting data into a network stream.
With functions, you can decompose an application into reusable software components, instead of a single interminable block of source code. A modular approach to programming makes an application more readable and maintainable.
The function name should convey the purpose of the function. For example, a function named factorial would execute the factorial algorithm and then return the result directly or indirectly ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access