Answer the question
In order to leave comments, you need to log in
How to combine the factory and the law of Demeter?
Good evening.
Zayuzal once again an abstract factory, and suddenly remembered that a class method should not refer to objects that any method returned. It turns out that using factories is a necessary evil, and code with factories is a priori worse than code that follows the law of Demeter? After all, even if I just return an object from the function without calling it, another class will violate this law.
If this is a matter of convenience, what is objectively better to ignore in most cases? Are factories almost an anti-pattern to be avoided to the last? And is there a solution that allows you to sit on two chairs?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Zayuzal once again an abstract factory, and suddenly remembered that a class method should not refer to objects that any method returned.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question