7
In a contest, I found the following question:
In Object-Oriented Programming, the law of Demetrius (Law of Demeter) says that a method m of an O object should not invoke methods of following object types: (A) of O itself. (B) parameters of m. (C) any object created/instantiated in m. (D) objects returned by called other methods. (E) O attributes. (Specific Knowledge - System Analyst - q54 - 2013 )
Among these, the right answer would be "(C) any object created/instantiated in m" according to the template.
What’s this Demetrius Law about?
"we can only invoke methods ... (of) any object that is created or instantiated by the method", but the answer C given in the question says exactly the opposite: "a method m of an object O should not invoke methods ... (from) any object created/instantiated in m". Then the answer is wrong?
– Woss