Questions tagged [law-of-demeter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
97 views

Using Spring Boot's @ConfigurationProperties without violating Law of Demeter

My apps commonly have one or more prop holders. These holders contain config data used in the app such as: @Component @ConfigurationProperties(prefix="app.orders") @Data //lombok public class ...
1
vote
1answer
131 views

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.
4
votes
4answers
420 views

How to deal with Law of Demeter in the product - owner relationship?

I want to display the product, and the product card has a lot of information about the product and the owner. How to deal with Law of Demeter in this product - owner relationship? In controller I ...
7
votes
3answers
754 views

Does this violate the Law of Demeter?

Let's say I have a class SelectableEntity<T extends Entity> which has three methods, select, deselect, isSelected and count. To take a somewhat contrived example, let's say I'm building an ...
3
votes
2answers
615 views

Demeter's law vs method chaining: when to use which?

Given this code from the Symfony framework: use Symfony\Component\HttpFoundation\Request; public function indexAction(Request $request) { $request->isXmlHttpRequest(); // is it an Ajax ...
4
votes
1answer
303 views

Dealing with a large interface

I'm working on a program that solves a certain type of systems of equations. The main data objects are Equation, Variable, Solution. Then I have this interface, which represents all things that I want ...
0
votes
1answer
85 views

Should an object keep a reference to a sibling object, or access through mutual owner's method

For context, I'm building a GTK+ application in C where a subclass of GtkApplicationWindow creates and displays a subclass of GtkToolbar and a GtkNotebook (a widget with multiple pages that can be ...
13
votes
5answers
2k views

According to Demeter's law, is a class allowed to return one of its members?

I have three questions concerning Demeter's law. Apart from classes which were specifically appointed to return objects - such as factory and builder classes - is it okay for a method to return an ...
2
votes
2answers
699 views

Law of Demeter and its applicability

Let's say I'd like to perform the following command: house.getFloor(0).getWall(WEST).getDoor().getDoorknob(); To avoid a NullPointerException, I'd have to do the following if: if (house != ...