Hi,
how do you go about ordering elements inside a class (apart from the obvious "variables at the top functions below")
Alphabetical, by function, any other logic?
E.g. when type/name/value would be the the order of importance of 3 parameters...
Would you prefer scheme1 or scheme2?
Obviously with only 3 parameters it doesn't matter but when it is becoming more and also in cases where a parameter is added at a later date, it could matter.
Anything from your experience giving clues about pros and cons?
Scheme1, by importance
class MyClass
{
private $_type = '';
private $_name ='';
private $_value ='';
public function setType()
{
}
public function setName()
{
}
public function setValue()
{
}
}
Scheme2, alphabetical:
class MyClass
{
private $_name ='';
private $_type = '';
private $_value ='';
public function setName()
{
}
public function setType()
{
}
public function setValue()
{
}
}