Why does Zend discourage "floating functions"?
- by kojiro
Zend's Coding Standard Naming Convention says
Functions in the global scope (a.k.a "floating functions") are permitted but discouraged in most cases. Consider wrapping these functions in a static class.
The common wisdom in Python says practically the opposite:
Finally, use staticmethod sparingly! There are very few situations where static-methods are necessary in Python, and I've seen them used many times where a separate "top-level" function would have been clearer.
(Not only does the above StackOverflow answer warn against overuse of static methods, but more than one Python linter will warn the same.)
Is this something that can be generalized across programming languages, and if so, why does Python differ so from PHP? If it's not something that can be generalized, what is the basis for one approach or the other, and is there a way to immediately recognize in a language whether you should prefer bare functions or static methods?