My Comment on the BCL/FCL vs. primative types debate.

I've been reading some of the posts about BCL/FCL vs. primative types. It seems to me that the bigger question is:
Do you use the features of your tool? Here is an example:

In C# if I do this:

int a = 5;

Its the same as this:

System.Int32 a = 5;

I am of the opinion that you should use all the features of the language that you have chosen. If you start to code
only to the framework types where do you stop following that line of thinking? For example:

        lock (x) ...

is the same as:

      System.Threading.Monitor.Enter(x);

      try {

            ...

      }

      finally {

            System.Threading.Monitor.Exit(x);

      }

 
Should I code only using the framework types in this case as well? I say no. 
The using keyword is another example. All it does is insert a call to dispose.
      using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font("Arial", 10.0f))

      {

            // use MyFont and MyFont2

      }   // compiler will call Dispose on MyFont and MyFont2

 
This is more of what Don Box so affectionately calls "syntactic sugar". If I use these 
constructs in my C# code will I just become a coding diabetic from all the "syntactic sugar"?
Let’s just say that my opinion is "How sweet it is".
The only thing that I can think of to justify foregoing language specific features is CLS compliance. 
If you’re developing code to be used by any .NET language then you have to pay special attention to
language features that are not CLS compliant. This is usually very easy to check using a compiler
setting.

2 Comments

  • For the record, FCL (framework class library) is just another acronym for the BCL (base class library). They're used rather interchangeably. I believe what you mean is BCL/FCL types vs. primitive types. Primitives being types that a given compiler gives "special attention."

  • Woops... good catch.... off to the edit room :P


Comments have been disabled for this content.