While not intended to define an end all be all standard of class organization conventions, I would like to toss out an idea for a "loose" convention perhaps we should try to stick to (even if remotely closely) in order to achieve some better code readability.

These represent a logical hierarchy:

1. visibility first, then static (if applicable). As noted in the php manual: http://us2.php.net/manual/en/language.oop5.static.php
   eg: public static $my_static = 'foo';
       protected $_thing = 'blah';

2. all properties at the top of the class definition, methods to follow.

3. within all methods, all statics at the top of the definition, instance methods follow.

4. within the static or instance method group, methods should be orgainized by visibility, specifically public first, protected second, private last.

5. within each visibility grouping functions grouped by logical execution, developer need, etc. For example: setOptions() would be before start() which would be before stop() since that would be the most logical order of usage.

Method naming has been covered in the coding standard, as has the conventions within code.

Any Ideas?

-ralph

Reply via email to