I'm looking for a reference to clean coding styles that I can pass to a team member.
In particular, the rule that a method should not change its return type based on an input parameter. If you need different output, use a different method.
Example:
$invoice_items = getInvoiceItems();
$total = getInvoiceItems( TRUE );
To me, this is bad coding style (and I'm not even talking about a parameter whose meaning can't be determined from the calling code).
The above example should actually be:
$total = totalInvoiceItems();
... where totalInvoiceItems()
might call getInvoiceItems()
to get the items it needs to total.
Where would I find a reference to this (and possibly other important coding style rules)?