Say you're declaring a class with all the bells and whistles - constructor and destructor, public, private, protected and static methods and properties, magic methods, etc.
How do you organize all this logically? For instance, do you group things by visibility? Do you alphabetize method names? Do you group magic methods together? Do you put the constructor at the beginning and the destructor at the end?
Obviously this is subjective, but I'm curious to hear what has worked for others, or what you find easy to navigate when reading others' code.
If I have time, I try to put them in alphabetic order ;P
like this
class Foobar
{
var $public;
function __construct(....
function public_method_1()...
function public_method_2()...
//
var $_priv;
function _private_1()...
function _private_2()...
}
basically, most interesting (for class users) stuff first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With