Enterprise Library 5.0 – Notes

The new version of Enterprise Library has some interesting implied additions and constraints.  I have used the frameworks before and like them for the most part, they keep the structure of a large application from looking like slop.  I took a good look at it and I am impressed how much better the library gets in each release.  In our organization however, we have chosen not to use the framework because we used the first few and converting from 1.0 or 1.1 to 2.0 to 3.1 was a royal pain.  Several applications used 3 and 4 but they soon converted to the Castle framework because the Castle team seemed to be making more progress.  Both have pros and cons which you may assess for yourself if your interest level is high enough.

What I do want to note is the lack of expressed Windows XP support with the Enterprise Library 5.  Here is the beginning of the system requirements section:

System Requirements Screenshot

I saw a comment asking if Windows XP was supported and the reply was that if it works, it works.

There are a ton of breaking changes this time, but none appear to be outside the realm of making things better in the long run.  There is also a Migration Guide as usual to help in the transition process.

Great job on the release and I hope to see more good things from the Enterprise Library in the future.

iPad Second Impressions

The iPad has been released with all the fanfare of a king arriving home from a great battle.  iTunes has been updated to support the new applications. New applications specifically designed to support the iPad are well underway.  Now all of us skeptics can be silenced, or not.

I realized the cleaver plan of Apple a few hours after the release.  I have thought hard why anyone would want a larger iPhone other than it’s a gadget of bigger proportions.  The reason became clear when a read a blog post of an eBook reader that was very pleased with the iPad and it’s screen, form factor and overall size and weight.  Weeks ago I read that school books were to be available for the iPad.  Then I put it together, the iPad is the perfect medium for a student to carry a single lightweight device rather than a bunch of heavy books.   The school system doesn’t have to carry as many books (maybe none in the future) and the students only have to carry a gadget to their classes, brilliant.

I am sure there are people out there that are saying “Why does it have to a tablet, why not a netbook or Macbook or the like.”  The problem with a PC, Mac or Linux machine is the potential for data loss.  The iPad only has the data that has been synced with a computer so if it gets fried, dropped, drowned or just fails, the data is still on the computer.

I officially rescind my previous skeptical post and say the iPad is a gadget worth getting.

When is CRUD enough?

Let’s lay some groundwork before we start the rant.

CRUD is an acronym for the Create, Read, Update and Delete operations done to tables in a database.  I believe I can safely say “All database applications do at least the CRU of the CRUD”.

Now for the argument

I have never dealt with an enterprise level application that does just plain old CRUD.  In every case, there was some sort of logical requirement that precluded the CRUD requirement.  In the academic world there are examples of applications where CRUD operations can be done, but I have not been involved with one for a very long time.

Here’s an example:

Tables: UserInfo, ProductInfo, EventHistory

Assume EventHistory is a generic event history table with the key from the foreign table (UserInfo, ProductInfo, etc.)

Now, let’s add a new UserInfo record with the appropriate EventHistory record, this would require an Insert of the  UserInfo record with the retrieval of the key column then a write to the EventHistory table to record the user and such of the action.  Two trips even in a transaction, bleh.

How about writing a stored procedure to do the same.  One trip with little overhead to the calling application.  Simple, nice.

I’m sure there are a ton of people saying it could be done in a trigger and yet others think it should be done in the business application layer but in my opinion, the database is a good place to database oriented things.

Apple iPad First Impressions

The announcement of the Apple iPad has left me a little unimpressed.  I have watched Apple release all kinds of technology over the years.  While many of the Apple products over the years have not been technological marvels, they have released products that were well thought out from a hardware perspective as well as a software perspective.  For example, the iPod would never have become as popular if iTunes was not the song management software included with it.

The iPad seems to be a year or two too late for the market.

Does it make a good e-book reader?  It seems as if the market for the portable e-book reader came of age when the Kindle hit the market and has been followed by many other readers geared toward the reader of e-books.  I doubt Apple has truly targeted the iPad as an e-book reader exclusively.

Does it make a good connected device?  The netbook market is full of computers capable of surfing and some include 3G.  Some are running Windows others Linux and sometime soon Chrome OS.  One of the odd things about the iPad is the requirement for it to be connected to a computer (Mac or PC) in order to synchronize it’s data.  While not a bad idea considering a drop could be fatal, it does lead to the next question.

Does it make a good computer?  In a world where just about everything is a computer, I would say the iPad does not make a good computer.  One cannot install Mac programs like Garage Band or any of the other software that would be perfect to take on the road.   No dice.  The iTunes store is the location to get software for the device just like an iPod or iPhone and while this has proven to be a good medium for applications it begs the question of cost.  I would have to buy another program like Garage Band for the iPad.

Like the rest of the world, I have not played with the iPad and I have not worked with it to any extent.  I very much hope it is a good device but I am very skeptical.

SQL Server: Like with Underscores

There are times when you need to do a LIKE based search and need to find an underscore.  I was surprised to find the underscore is reserved as a single character wild card.

There are two ways to get this done.  First is the explicit ESCAPE definition as follows where the backslash is the escape character.

-- looking for anything with an underscore
SELECT  *
FROM    dbo.SomeTable
WHERE   ColumnName like '%\_%' ESCAPE '\'

To me, a better approach is surrounding the character is square brackets.

-- looking for anything with an underscore
SELECT  *
FROM    dbo.SomeTable
WHERE   ColumnName like '%[_]%'

The second approach may get a little confusing when looking for brackets though.

-- Looking for '[' + sometext + ']'
SELECT  *
FROM    dbo.SomeTable
WHERE   ColumnName like '%[[]%[]]%'

Hope this helps.

ASP.NET Code: Register Script in Head Section

Registering a client-side script in ASP.NET is normally done with the Page.RegisterClientScript or Page.RegisterClientScriptInclude.  Both of these add the appropriate script reference into the resulting body of the HTML.  However there are times when it is nice to have the script added to the head section of the page.  I have written two extension methods to accomplish the task using the same naming convention as the Microsoft provided functions.

        /// <summary>
        /// Registers the client script include in the head section.  If the
        /// same ID is sent, the source file is replaced with the new one.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="id">The control ID to make sure there aren't two
        /// registered under the same ID</param>
        /// <param name="src">The file name.</param>
        public static void RegisterHeadClientScriptInclude(this Page page, string id, string src)
        {
            HtmlGenericControl si = null;
            foreach (Control c in page.Header.Controls)
            {
                if (c.ID != id) continue;
                si = (HtmlGenericControl) c;
                break;
            }
            if (si == null)
            {
                si = new HtmlGenericControl { ID = id, TagName = "script" };
                si.Attributes.Add("type", "text/javascript");
                si.Attributes.Add("src", src);
            }
            else
            {
                si.Attributes["src"] = src;
            }
            page.Header.Controls.Add(si);
        }

        /// <summary>
        /// Registers the client script code block in the head section of the page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="id">The id.</param>
        /// <param name="code">The code.</param>
        public static void RegisterHeadClientScriptBlock(this Page page, string id, string code)
        {
            HtmlGenericControl si = null;
            foreach (Control c in page.Header.Controls)
            {
                if (c.ID != id) continue;
                si = (HtmlGenericControl)c;
                break;
            }
            if (si == null)
            {
                si = new HtmlGenericControl { ID = id, TagName = "script" };
                si.Attributes.Add("type", "text/javascript");
            }
            si.InnerText = code;
            page.Header.Controls.Add(si);
        }

Please comment if you find it interesting or crap, I would like to know either way.

Pump-Up a Bagel

I love everything bagels but the local place sometimes runs out but I have a solution to the problem.   McCormack makes these spice grinders and I found the Italian Herb grinder to be perfect.  So here’s the recipe:

Bagel, cream cheese, McCormack Italial Herb Seasoning Grinder

Smear up the bagel as normal, grind on the seasoning and flavor love is on the way.

Links:
McCormack Site: The Italian Herb Seasoning Grinder