previous |
start |
next
Law of Demeter
- The law: A method should only use objects that are
-
- instance fields of its class
- parameters
- objects that it constructs with new
- Shouldn't use an object that is returned from a method
call
- Remedy in mail system: Delegate mailbox methods to mail
system
mailSystem.getCurrentMessage(int mailboxNumber);
mailSystem.addMessage(int mailboxNumber, Message msg);
. . .
- Rule of thumb, not a mathematical law
previous |
start |
next