Take a look at the code below. It a short example of what happens when the language is a little too explicit. In most cases all you want to know is if anything is in a variable, usually a string. A simple way to determine if a property is empty is all you want. It’s silly to jump through the hoops of determining if it’s null, if it’s child is null, and if it’s child actually has something interesting in it.
Things like this make me wonder if the languages designers had actually programmed in the decade before they designed this. Or had they been working on theoretical mathematics.
if ( inputField != null )
{
if ( inputField.validation != null )
{
if ( inputField.validation.minValue != null )
{
if (inputField.validation.minValue.Length > 0)
{
…
Should be:
if (inputField.validation.minValue.Length > 0)
{
…
Unless, you actually care to catch the reasons why the various other items are null.
Really, the worst part is the string comparison. Why doesn’t ..minValue.Length return 0 when minValue is null. How often does that little difference matter? Mostly, it matters if the field came from a database. But if you care about that you need an additional test, because null is not the same as DBNull.