Law of Demeter

     Researchers have formulated a rule called the “Law of  Demeter” (Lieberherr and Holland 1989) which essentially states that Object A can call any of its own routines. If Object A instantiates an Object B, it can call
 any of Object B’s routines. But it should avoid calling routines on objects provided by Object B. In the account example above, that means
      account.ContactPerson() is OK, but
      account.ContactPerson().DaytimeContactInfo() is not.

你可能感兴趣的:(em)