Why does Zend discourage "floating functions"?

Posted by kojiro on Programmers See other posts from Programmers or by kojiro
Published on 2012-12-18T18:48:41Z Indexed on 2012/12/18 23:12 UTC
Read the original article Hit count: 250

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?

© Programmers or respective owner

Related posts about php

Related posts about python