Zend Framework

Class Member Organizational Conventions

Details

  • Type: Coding Standards Violation Coding Standards Violation
  • Status: Resolved Resolved
  • Priority: Trivial Trivial
  • Resolution: Not an Issue
  • Affects Version/s: 0.2.0
  • Fix Version/s: Next Minor Release
  • Component/s: None
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

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:

http://www.nabble.com/Class-member-orgainizational-conventions-tf2508874s16154.html#a6996153

  1. Properties should appear at the top of the class definition followed by methods.
  2. Class members (both properties and methods) should be organized by visibility: public first, protected second, and private last.
  3. 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.
  4. Static methods should be listed before instance methods.
  5. Static methods should have the visibility written first, as illustrated in the php manual at http://php.net/manual/en/language.oop5.static.php:
    public static $myStatic = 'foo';
    public static function aStaticMethod()
    {}
  6. 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.

Issue Links

Activity

Hide
Ralph Schindler added a comment -

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

Show
Ralph Schindler added a comment - 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
Hide
Wil Sinclair added a comment -

This issue should have been fixed for the 1.5 release.

Show
Wil Sinclair added a comment - This issue should have been fixed for the 1.5 release.
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Ralph Schindler added a comment -

Updating project management info.

Show
Ralph Schindler added a comment - Updating project management info.
Hide
Wil Sinclair added a comment -

Updating to comply with new IT component conventions.

Show
Wil Sinclair added a comment - Updating to comply with new IT component conventions.
Hide
Ralph Schindler added a comment -

Assigning to matthew.

Show
Ralph Schindler added a comment - Assigning to matthew.
Hide
Ralph Schindler added a comment -

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

Show
Ralph Schindler added a comment - Closing as not an issue. ZF1 is near end of production/new features, and focus will now be on ZF2 for coding conventions, etc.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1d
Original Estimate - 1 day
Remaining:
1d
Remaining Estimate - 1 day
Logged:
Not Specified
Time Spent - Not Specified