Description

Ralph Schindler proposed a series of class member organizational conventions that we can adopt for improving the readability and consistency of the framework code base. I've modified them slightly for clarity and to include others' responses to the mailing list thread:

Properties should appear at the top of the class definition followed by methods.

Class members (both properties and methods) should be organized by visibility: {{public}} first, {{protected}} second, and {{private}} last.

Special methods such as {{__construct()}}, {{__destruct()}}, {{__clone()}}, {{__sleep()}}, {{__wakeup()}}, {{__get()}}, {{__set()}}, {{__isset()}}, {{__isset()}}, {{__unset()}}, {{__call()}}, {{__toString()}}, and {{__set_state()}} should appear first in the list of methods, in the order presented here, as needed by the class.

Finally, methods should be grouped logically by execution order, developer need, etc., where appropriate. For example: {{setOptions()}} appears before {{start()}}, which appears before {{stop()}}, since this is the most logical order of usage.

Comments

Posted by Ralph Schindler (ralph) on 2006-12-27T13:35:59.000+0000

We currently have a rift on this issues as wether visibility comes before static or not. We should all voice our opinion on the matter, as i see this is more a matter of taste than objective fact, and based off what has been brought up, come to a decision on this.. perhaps have a hammer come down from the powers that be.. Bill? Hehe.

But seriously, lets get this decided and put into the coding standards doc.

We all want fresh and clean code :)

Posted by Wil Sinclair (wil) on 2008-03-21T17:05:30.000+0000

This issue should have been fixed for the 1.5 release.

Posted by Wil Sinclair (wil) on 2008-04-18T13:11:47.000+0000

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Posted by Wil Sinclair (wil) on 2008-04-18T17:09:40.000+0000

Please evaluate and categorize/assign as necessary.

Posted by Ralph Schindler (ralph) on 2008-04-22T11:35:30.000+0000

Updating project management info.

Posted by Wil Sinclair (wil) on 2008-06-15T21:44:45.000+0000

Updating to comply with new IT component conventions.

Posted by Ralph Schindler (ralph) on 2009-01-09T10:32:46.000+0000

Assigning to matthew.

Posted by Ralph Schindler (ralph) on 2011-02-17T13:01:17.000+0000

Closing as not an issue. ZF1 is near end of production/new features, and focus will now be on ZF2 for coding conventions, etc.