in reply to Unlimited chaining (is there a way to detect this?)
Martin Fowler calls this a "fluent interface": http://martinfowler.com/bliki/FluentInterface.html
The idea behind it is that methods that are simply setting object state return the object instance; this can improve readability in many instances, particularly if you align the '->' pointers vertically, and can be used to build constructs that have a natural linguistic flow -- hardly 'dumb' code.
As for detecting it... simply don't write such constructs; the only way you'd be able to programmatically generate such a construct is to pass it to eval, and eval is rarely the right answer.
|