K
Karsten Wutzke
Hello!
When programming I keep switching the order of declared fields, method
params (especially for constructors) and sometimes methods themselves
in the class.
-> Is there a specific order recommended? <-
For constructors:
Mostly I keep ordering them in "most mandatory order first". I put
those in the param list first, probably coming off some PHP coding
where you can omit passing optional method params at the end:
function do_something($param1, $param2, $param3, $param4 = null,
$param5 = "black")
{
....
}
=> Calling do_something(1, "dfgdf", 0); is perfectly valid.
Is it better to keep "mandatory order first", use "order by topic",
e.g. group somewhat related params whether mandatory or optional. Or
another?
Karsten
When programming I keep switching the order of declared fields, method
params (especially for constructors) and sometimes methods themselves
in the class.
-> Is there a specific order recommended? <-
For constructors:
Mostly I keep ordering them in "most mandatory order first". I put
those in the param list first, probably coming off some PHP coding
where you can omit passing optional method params at the end:
function do_something($param1, $param2, $param3, $param4 = null,
$param5 = "black")
{
....
}
=> Calling do_something(1, "dfgdf", 0); is perfectly valid.
Is it better to keep "mandatory order first", use "order by topic",
e.g. group somewhat related params whether mandatory or optional. Or
another?
Karsten