1 / 5

Formulating Law of Demeter for Static Methods

Understand how Law of Demeter (LoD) is applied to static methods, regulating object interactions. Learn about message sending restrictions within static methods and the objects they can access. Discuss the implications of LoD on design decisions and static method behavior.

kiril
Download Presentation

Formulating Law of Demeter for Static Methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Forms of LoD

  2. 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

  3. 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?

  4. 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.

  5. 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.

More Related