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