☞ | ![]() ![]() |
14 |
Functions should avoid using global variables
Why do we have functions?
For modularity
Benefit 1: Understand the function in isolation
Benefit 2: Reuse the function in another program
Using global variables in functions defeats both of these
Use functional parameter-passing mechanisms wherever possible
Global Variables are red flags
☞ | ![]() |
☞ |