The Law of Demeter

Superb article on The Law of Demeter. If you’re a programmer and don’t know what this is, stop whatever you’re doing and read Avdi Grimm’s article.

I’ve read about Demeter before, but I’ve never seen it described so clearly, with such excellent examples, and in such detail. For extra credit, read through the thoughtful comments. There’s a healthy debate about how strictly one should enforce Demeter in one’s code. Avdi is a “strict constructionist” while others, including Railscasts.com’s Ryan Bates, are willing to bend the law when convenient… though Avdi’s article makes a strong case that bending the law a little can lead to major headaches as your code base grows.

Posted by James on Thursday, July 07, 2011