I read a long time ago about a rule that using an object we shouldn’t point from one class to the other due to null possibility.
class Foo
{
public Bar Bar1 {get; set;}
public Foo()
{
}
}
class Bar
{
public string Name{ get; set;}
}
Foo foo = new Foo();
foo.Bar1.Name;
what is the law or rule called after this pattern?
It’s the Law of Demeter
To quote some of it: