Quote from: netProphET at Feb 01, 2008, 12:45 AM
Nice write-up.
I’ve read some comments on string concatenation in the forums - should any thoughts about that be made official?
ie. "like {$this}" or ’like ’ . $this
.. or leave it up to the discretion of the coder?
I say discretion of the coder, or ultimately, consensus of those involved in contributing, on this one.
I don’t mind a few simple guidelines and principles under the guise of "Coding Standards", but I’d like to shy away from any inclusion of general PHP coding issues. Too many formal rules limits creativity, and IMHO, how one builds a string with variable replacements is an issue that really should be decided by based on the problem being solved.
Saying that all array indexes should be defined with single-quotes (one of the standards currently included in this list) is another example of this. There are simply times it’s more important to make code readable vs. optimize it for speed, times when it’s appropriate to use "like {$this} or ’like ’ . $that, etc. It’s a matter of context and I believe we should treat such matters on a case-by-case basis based on measurable evidence. I’m not necessarily arguing against or for this specific issue mind you (though I personally think "like {$this}" is much more readable in most situations), just don’t think we should worry ourselves with defining and maintaining standards for the numerous issues like this one, or the string concatenation one, that we could include.
But discussing these kinds of PHP coding tips, as well as tips specific to working with xPDO/MODx code, here in the forums will be a wonderful way to start hashing out content that can fill core committer and add-on developer guides based on the appropriate consensus in each culture. Working on making it much easier to contribute so this knowledge doesn’t get lost here either...