Questions tagged [law-of-demeter]
13 questions
35
votes
1 answer
Is this a good scenario to violate the Law of Demeter?
I have this code in some part of an application:
long sum1 = new Multiples().ofAny(new long[] { 3, 5 }).until(32768).sum();
long sum2 = new Multiples().ofAll(new long[] { 3, 5 }).until(32768).sum();
long sum3 = new…
user218158
7
votes
3 answers
Does this violate the Law of Demeter?
Let's say I have a class SelectableEntity which has three methods, select, deselect, isSelected and count.
To take a somewhat contrived example, let's say I'm building an emergency messaging application that allows me to message to…

NRaf
- 301
4
votes
1 answer
What does the Law of Demeter have to do with Demeter?
Is there a story from Greek mythology about the goddess Demeter that somehow motivates the Law of Demeter? If so, I'd love to know it so I can tell it to my students when I teach this topic.

dinosaur
- 149