Let\'s start with Wikipedia:
More formally, the Law of Demeter for functions requires that a method m of an object O may
The 5th is difficult to represent in C# or Java, since they don't technically support global variables. However, in a design pattern that is similar in principle, you could have e.g. a configuration class that just contains globally-accessible static configuration values, such as (C#):
internal class MyConfiguration
{
private static String MyConfigurationValue; // set in constructor
MyConfiguration(){ MyConfigurationValue = DoSomethingToLoadValue(); }
public static String GetMyConfigurationValue(){ return MyConfigurationValue; }
}
In this case (assuming the design pattern was acceptable in all other ways), the Law of Demeter would allow this, since it is globally accessible and intended to be that way.