Funtion naming and actions - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Feature Requests (http://get-simple.info/forums/forumdisplay.php?fid=7) +--- Thread: Funtion naming and actions (/showthread.php?tid=2284) |
Funtion naming and actions - hameau - 2011-10-16 Hello, A recent forum reference to this wiki page, showing new functions appearing in v3.1, prompted this request. On that wiki page, there are three naming styles for functions that fundamentally do the same thing: get, return and echo. I would like to propose that function naming should follow a more consistent format, so that any data-fetching function is named 'get...', with a switch as the final parameter to select 'echo' or 'return', this switch having a system-wide default value. Ideally, this philosophy should be extended to all the core functions and included in the Coding Guidelines for contributors, too. Further, if this same idea could be extended to all core functions, they would all provide the flexibility of choice – to echo or return the result – making them more useful for more sophisticated data manipulation (rather than simply echoing content to output). I know that changing core functions is a painful process, but feel that it would provide a much more solid foundation for future GS development, as well as a rather less frustrating experience for GS developers and site developers alike. At least, if new functions can be more consistent there will be less work to do in the future! Discuss. ;-) Funtion naming and actions - mvlcek - 2011-10-16 hameau Wrote:I would like to propose that function naming should follow a more consistent format, so that any data-fetching function is named 'get...', with a switch as the final parameter to select 'echo' or 'return', this switch having a system-wide default value. Ideally, this philosophy should be extended to all the core functions and included in the Coding Guidelines for contributors, too. I personally don't like this parameter $echo at all:
Im my plugins I'm using the 2.0 syntax:
The prefered way IMHO would be
Funtion naming and actions - lacroixca - 2011-12-05 I agree so much on the $echo parameter! WordPress does it well by using the following syntax: get_something() to return a value & the_something() to output it. This should become standard. |