I am use to seeing instance and class variables at the beginning of
class definitions, then constructors and destructors. The rest, I
expect to search for with a few keystrokes in vim.
I rarely notice other differences in the organization of the source code
for classes.
Cheers,
Gavin
Allard Buijze wrote:
I agree with both of you.
However, I think that the construction should be mentioned as well. In
my project here, we put the constructor (no matter what its visibility
is) as the first method in the class. What do you think?
Regards,
Allard
On 10/26/06, Darby Felton <[EMAIL PROTECTED]> wrote:
These look like good conventions that we could follow in order to
achieve greater consistency and increased readability of the framework
code base. Though I wouldn't want such conventions to slow any current
development, it would be nice to have such conventions in place to help
make a quality 1.0.0 release.
Others' thoughts?
Best regards,
Darby
Ralph Schindler wrote:
> 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