The Law of Demeter Is Not A Dot Counting Exercise
Posted by: youve been HAACKED,
on 14 Jul 2009 |
View original | Bookmarked: 0 time(s)
Recently I read a discussion on an internal mailing list on whether or not it would be worthwhile to add a null dereferencing operator to C#. For example, one proposed idea would allow the following expression. object a = foo.?bar.?baz.?qux;
This would assign the variable a the value null if any one of foo,bar, or baz is null instead of throwing a NullReferenceException. Its a small, but potentially helpful, mitigation for the billion dollar mistake.
Sure enough, it did not take long...