Discouraged by Object Oriented Programmings, Many mixed languages support it. And developers abuse them.
Problems
Coupling
Readability
Maintainability
Testability
Solutions
- Wrap the function in a context object.
Examples
- External Resources Access, Database access, Time and Operation System resources.
Sample Code
Wrong
Right
Detection
Many modern languages avoid them. For the permissive ones, scope rules can be applied and automatically checked.
Tags
- Global
Conclusion
Structured programming considers global functions harmful. Yet, we can observe some bad practices cross paradigm boundaries.
Relations
- Singleton and Classes are global points of access.
More Info
Credits
The road to programming hell is paved with global variables.
Steve McConnell
Discussion (0)