Questions tagged [law-of-demeter]
The law-of-demeter tag has no summary.
13 questions
1 vote
3 answers
978 views
Python: Is returning self in method chaining a violation of Demeter's law?
In Python it is very common to see code that uses method chaining, the main difference with code elsewhere is that this is also combined with returning an object of the same type but modified. This ...
2 votes
4 answers
1k views
Is using getter method violating the law of Demeter?
Suppose I have a Attendance class public class Attendance { private PersonInfo personInfo; public PersonInfo getPersonInfo() { return personInfo; } } And I want to check if person is ...
0 votes
2 answers
3k 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 ...
4 votes
6 answers
1k 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 ...
3 votes
2 answers
2k 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 ...
0 votes
2 answers
191 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 ...
3 votes
2 answers
1k 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 != ...