50 likes | 148 Views
Forms of LoD. Notes. o/s: if an illegal message sending is possible assuming each decision taken both ways and each loop is executed 0 or more times. c/d: not interesting, because c/s. If dynamically: do o/d. Note. The following: aFoo.getPart().getPart(). getBar().getBp().test();
E N D
Notes • o/s: if an illegal message sending is possible assuming each decision taken both ways and each loop is executed 0 or more times. • c/d: not interesting, because c/s. If dynamically: do o/d
Note The following: aFoo.getPart().getPart(). getBar().getBp().test(); Should not be allowed in a static method. Next follows a generalization of LoD to static methods (slide after next). Do you agree?
Object form for regular methods • Within a method, messages can only be sent to the following objects: • 1. A parameter of the method, including the enclosing object • (this or self); • 1.1. For pragmatic reasons: a global object; • 2. An immediate part object (computed or stored): • 2.1 An object that a method called on the enclosing object returns, including attributes of the enclosing object; • 2.2 An element of a collection which is an attribute of the enclosing object; • 3. An object created within the method.
Object form for static methods • Within a static method, messages can only be sent to the following objects: • 1. A parameter of the method, including the current class; • 1.1. For pragmatic reasons: a global object; • 2. An immediate static part object (computed or stored): • 2.1 An object that a static method called on the current class returns, including static attributes of the current class; • 2.2 An element of a collection which is a static attribute of the current class; • 3. An object created within the method.