该编程规则的名称是什么?
有一个编程“规则”,规定方法在需要知道“xyz”时不应询问“x”,而应直接询问“z”。 我只是记不起名字了。
There is a programming "rule" that says that a method should instead of asking for 'x' when it needs to know 'x.y.z', ask directly for 'z'. I just can't remember the name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定这是否正是您所追求的,但这听起来非常类似于德米特法则< /a>.
I'm not sure if it's exactly what you're after but this sounds very similar to The Law of Demeter.
它被称为德墨忒尔定律(又名最少知识原理)。
请参阅http://en.wikipedia.org/wiki/Law_of_Demeter。
我听过的最生动、最难忘的例子是“当你在商店付款时,店员不会要求你提供钱包,这样他们就可以提取钱,他们会要求你提供钱包”钱!”
It's known as the Law of Demeter (a.k.a. Principle of Least Knowledge).
See http://en.wikipedia.org/wiki/Law_of_Demeter.
The most vivid and memorable illustration of it I've heard was "When you're paying for a purchase in a store, the clerk doesn't ask you for your wallet so they can extract the money, they ask you for the money!"
你在想德墨忒尔法则吗?
Are you thinking of the Law of Demeter?