Coupling, Cohesion and the Law of Demeter

前端 未结 6 1545
南旧
南旧 2020-12-02 05:53

The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you

6条回答
  •  一整个雨季
    2020-12-02 06:12

    It’s a grey area. These principals are meant to help you in your work, if you find you’re working for them (i.e. they’re getting in your way and/or you find it over complicates your code) then you’re conforming too hard and you need to back off.

    Make it work for you, don’t work for it.

提交回复
热议问题