|
|
|
|
|
by birken
5508 days ago
|
|
We actually had a debate in our engineering dept about how we wanted to handle functions like this, and in the end decided on tt_function_name() in the global function space. We decided against putting them in explicit namespaces, because we felt these were convenience functions and they should be convenient to use. We felt the convenience of: if (tt_str_startswith($url, 'https://)) {
} over something like: if (tt/global/string/starts_with($url, 'https://)) {
} was worth the lack of organization. We have <10 of these types of global functions in our code base and we are very careful about adding new ones. All other classes and functions are either in a namespace or class context. We went with the tt_ prefix because we wanted to cover our bases and really explicitly ensure we never will collide with a PHP function, and we felt it isn't too unwieldy. As for using a singleton class, since 5.3 we prefer to use namespaces instead. |
|