The interesting thing about method Pointers is that their use can be an indication that the code violates the Law of Demeter.
关于方法指针,有意思的事情是:它们的使用可能就表明代码违反了迪米特法则。
In Listing 9, you can see how this code demonstrates the Law of Demeter — and how it could be used to wreak havoc with people's wallets!
在清单9中,可以看到这些代码演示了迪米特法则——如何用它洗劫人们的钱包!
Lastly, the closure structure more closely follows the Law of Demeter since your object would, theoretically, be "reaching through" via the prototype chain.
最后,闭合结构更接近于得墨忒耳法自你的对象,从理论上讲,是“通过”通过原型链。
Using the motto Talk only to immediate friends, the Law of Demeter states that we should avoid invoking methods of an object that was returned by another object's method.
迪米特法则使用只与直接朋友对话这句格言指出:我们应当避免调用由另一个对象方法返回的对象上的方法。
Using the motto Talk only to immediate friends, the Law of Demeter states that we should avoid invoking methods of an object that was returned by another object's method.
迪米特法则使用只与直接朋友对话这句格言指出:我们应当避免调用由另一个对象方法返回的对象上的方法。
应用推荐