What guidelines does the least principle provide? A take any object; now from any method in that object, the principle tells us that we should only invoke methods that belong to any components of the object. 就任何对象而言,在该对象的方法中,我们只应该调用该对象的任何组件的方法。 B take any object; now from any method in that object, the principle tells us that we should only invoke methods that belong to objects passed in as a parameter to the method. 就任何对象而言,在该对象的方法中,我们只应该调用被当做方法参数传递进来的对象的方法。 C take any object; now from any method in that object, the principle tells us that we should only invoke methods that belong to the object itself. 就任何对象而言,在该对象的方法中,我们只应该调用该对象本身的方法。 D take any object; now from any method in that object, the principle tells us that we should only invoke methods that belong to any object the method creates or instantiates. 就任何对象而言,在该对象的方法中,我们只应该调用该方法创建或实例化的对象的方法。
时间: 2024-04-02 21:36:38 浏览: 103
MISRA C-2012 Guidelines for the C language in critical systems
B) Take any object; now from any method in that object, the principle tells us that we should only invoke methods that belong to objects passed in as a parameter to the method. The Least Principle, also known as the Least Knowledge Principle or the Principle of Demeter, states that a given object should have minimal knowledge of the other objects it interacts with, including only invoking methods on objects that are directly passed in as parameters to its methods.
阅读全文