.: Coalesce (??) Operator (C#) :.

3 08 2006

I get a kick when someone sees the coalesce (??) operator for the first time.  Usually I get questions like “does that actually compile?”.

 The answer is yes, it does compile.  Simply stated, the coalesce operator is a binary operator that returns the left hand side value if it is not null, otherwise it returns the right hand side.

Big whoopti doo right?  Actually, it is.  It’s a nice way to return a default value or ensure that you’re not returning nulls, especially when returning objects whose properties may be accessed.

MyObject.MyObjectProperty.PropertyField

How often have you encountered a null exception because the object returned by MyObjectProperty was null?  Below is an example that uses the coalesce operator in a lazy load get property.


public class MyObject
{
  public SomeClass MyObjectProperty
  {
      get
      {
          return (_localFieldObject ??
              (_localFieldObject = new SomeClass()));
      }
  }
}





:: Professional Certification ::

3 08 2006

I have mixed feelings about certifications; in my opinion, it is a double edge sword. In principle, certifications are supposed to provide some measure of competency, in some cases excellence, in a particular area. That is to say that if done correctly, it is something of value and a goal to be achieved. Granted that I’ve personally gone through the MCAD certification process and continuing through the MCSD process, there are two pet peeves I have about the entire procedure.

On the testing side, some of the focus of the questions center on details that can easily be looked up and referenced. I am of the opinion that concepts, such as how one component interacts with another, should have greater and majority of the emphasis rather than testing for something that the compiler would catch; i.e. questions related to syntax. That’s the one issue I have with the group administering the certification, the other is with the test takers.

I believe that those who take certifications that merely go through prep question examples and brain dumps are doing a disservice to those who take the time and effort to understand and absorb the material. It diminishes the certification’s value when individuals can get certified without necessarily comprehending the subject matter.

Neumont University includes with their program certifications for MCAD/MCSD (and the new upgrades), DB2, and Java. I would hope and encourage students to take advantage of this opportunity but not at the expense of trivializing the certification.