Hacker News new | ask | show | jobs
by robbrit 2538 days ago
I've never found that sticking strictly to the Law of Demeter makes your life that much easier for the reasons under "Disadvantages" in the article.

I prefer a more relaxed form of the law: you can do something like a.b().c(), where b is a method that returns an interface. I think of it as a "composite interface". You can repeat the nesting as much as you like, however it gets a little hard to read after a while.

1 comments

If you're trying to do b.c() you should inject b directly into your constructor