1

I believe there is a person who named this pattern or practice and would like to know the correct nomenclature to avoid confusion.

object.propertyA.propertyB

becomes

object.propertyB
2
  • 2
    The use of 'child' and 'parent' in the title suggests something to do with inheritance that isn't actually the case. Commented Jan 18, 2018 at 12:03
  • Thanks @SeanBurton - I've updated the title to (hopefully) make it clearer. Commented Jan 30, 2018 at 9:08

1 Answer 1

3

This is commonly referred as Law of Demeter

Here are a few guidelines (as per Wikipedia page):

  • Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
  • Each unit should only talk to its friends; don't talk to strangers.
  • Only talk to your immediate friends.

Some more reading: http://wiki.c2.com/?LawOfDemeter

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.