Beware of Microsoft’s Enterprise Library

A few years ago I read through most of this library and gave the coding a C to C+ grading. So, if you have weak developers or time constraints or whatever else is preventing you from creating a A or AAA framework then use it – it’s a rational choice.

 

Today, I started the morning interfacing to code that used it and some stuff would not load. Hit Pause in the debugger and started to step to see where the problem was.  The code was in the MEL, and I looked at the code and graded it around a C- to D. Microsoft has a problem with it’s continuous movement to contract resources which is further compounded by the loss of the best coders elsewhere (where there are floating options). Microsoft have traditionally paid prevailing wages and had used options to sweeten the pot to get the best. That no longer works…. I am fearful that the MEL will slowly deteriorate into Junk Code as it is more and more contractor-ized. Contractors rarely have commitment to good code – I’ve seen their contracting firm managers instruct them to maximize the hours by such items as intentionally not handling possible exceptions and verbose coding.

 

The code that I gave this grading to was in:

Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Storage.ConfigurationChangeWatcher

 

while (pollingStatus.Polling)
            {
                currentLastWriteTime = GetCurrentLastWriteTime();
                if (currentLastWriteTime != DateTime.MinValue)
                {
                    // might miss a change if a change occurs before it's ran for the first time.
                    if (lastWriteTime.Equals(DateTime.MinValue))
                    {
                        lastWriteTime = currentLastWriteTime;
                    }
                    else
                    {
                        if (lastWriteTime.Equals(currentLastWriteTime) == false)
                        {
                            lastWriteTime = currentLastWriteTime;
                            OnConfigurationChanged();
                        }
                    }
                }
                Thread.Sleep(pollDelayInMilliseconds);       
            }

 

The documentation states:

/// <para>Represents an <see cref="IConfigurationChangeWatcher"/> that watches a file.</para>

 

So instead of  269 lines of code in the file,  using a FileSystemWatcher would do the same and detect the changes sooner.

 

So remember the old saying “Nothing is free” and that applies to MEL – you will pay for it via a lost of performance, bugs, etc.  Again, if the grade of developers that you are working with is below the grade that wrote MEL --- then it’s a rational choice. If you have a better grade, you may wish to consider options carefully.

Comments

Popular posts from this blog

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

Yet once more into the breech (of altered programming logic)

Error : /ScriptResource.axd : Invalid viewstate.