Hacker News new | past | comments | ask | show | jobs | submit login

It's rather ironic how in object-oriented programming chaining is considered a bad practice, e.g., breaking the Law of Demeter.



> breaking the Law of Demeter

How so?

You have an instance. You're allowed to call methods or access properties of that instance. You're not supposed to call methods or access properties of properties.

So chaining is just:

    $foo.something().somethingelse().blah();
At each point you're getting a new instance and accessing that. You're never reaching inside of a property of that instance.


If GP is correct re failure propagation then this is monadic composition vs. OOP object chaining.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: