Avoid:
o.getSubPart100().getSubpart12().getsubpart17().doSth();
Do: make class subPart100 to export a facade method
- dosthWithSupart12And17();
s.t. the clients DO NOT depent on
(a) subPart100
(b) subPart12
(c) subPart17
(d) result of doSth()
/* iteratively, the subPart classes can do also a facade method for the work of their components */
Demeter: a class should depend only on its attributes + IMMEDIATE collaborators
Avoid:
o.getSubPart100().getSubpart12().getsubpart17().doSth();
Do: make class subPart100 to export a facade method
s.t. the clients DO NOT depent on
(a) subPart100
(b) subPart12
(c) subPart17
(d) result of doSth()
/* iteratively, the subPart classes can do also a facade method for the work of their components */
Demeter: a class should depend only on its attributes + IMMEDIATE collaborators