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.
+7
A:
I'm not sure if it's exactly what you're after but this sounds very similar to The Law of Demeter.
Yes, exactly, thanks!
Sverre Rabbelier
2009-05-15 22:22:33
Remember that there are always exceptions to the rule. Some projects intentionally break this law to implement Domain Specific Languages (DSLs). Check out JMock, for example.
InverseFalcon
2009-05-15 23:57:27
+7
A:
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!"
Stephen C. Steel
2009-05-15 22:24:08