« The K.I.S.S. of Death for User Interface Design | Main | Facing Your Web Monsters »

Road Blocks and Code Blocks

By Micha | September 19, 2007

A couple of weeks ago I alluded to my journey of discovery into server side web programming as being like an expedition over perilous, rocky terrain. Certainly the learning curve has been steep in places but I really enjoy the view from the top – when the answers to previously daunting questions can be finally seen with alleviating clarity.

So just for fun I thought I’d share with you one of the obstacles that I ran into recently. Like some boulder on the trail this one stopped me in my tracks for quite a while until I finally saw the answer.

Take a look below and see if you can solve the problem. You don’t even have to be a software engineer as long as you can stomach the bizarre appearance of SQL code – it will give you a glimpse of what software developers face everyday as they stare into their screens. If you ever wondered why engineers give you that glazed look when you ask them a simple question, it’s because they have a head full of stuff like this. So go easy on ‘em.

Really, it’s just a pattern matching exercise and to solve the problem you just have to spot the difference between the two chunks of code. The first snippet does not work and the second one does work. And naturally, the problem becomes increasingly hard to solve as a deadline approaches.

Here it is:

DOES NOT WORK:
SELECT a.title, a.teaser, a.contentItemId, a.typeId, s.sectionName AS secName
FROM contentItem a, section s
WHERE a.typeId > 200
AND a.deleted = 'N'

DOES WORK:
SELECT a.title, a.teaser, a.contentItemId, a.typeId, s.sectionName AS secName
FROM contentitem a, section s
WHERE a.typeId > 200
AND a.deleted = 'N'

Did you find it? Well it took me a while – first to narrow the problem down to these two cases and then to see the difference between them. Have fun with it!

The Official User Advocate Group Hat

And just to make it more interesting I’ll even send this stylish-all-purpose-indoor-outdoor-official-User-Advocate-Group-baseball-cap to the first person who sends me the right answer in the comment section.

Now that’s really worth racking your brains for, huh?

Update:
So we have a winner. Dan was first to get his correct answer in. Thanks Dan, I owe you a hat! Thanks also to Pierre for adding his comment and to the folks who checked it out and sent me replies ‘offline’.

Update 2:
So I traveled all the way to Kanata, Ontario for the presentation of the Grand Prize to Dan (and also for a nice lunch with the gang).

The Prize Winner!

Topics: Geekness, coding, understanding technology |

5 Responses to “Road Blocks and Code Blocks”

  1. Dan Says:
    September 19th, 2007 at 9:52 am

    FROM contentItem a
    FROM contentitem a

    Darn case sensitivity!

  2. Pierre Doiron Says:
    September 19th, 2007 at 12:08 pm

    contentitem/contentItem in the FROM section of your queries differ in case.

  3. Michael Says:
    September 19th, 2007 at 1:23 pm

    Yes, the case sensitivity was the issue. But the part that really threw me in this case (pun intended) is that the ‘broken’ code ran perfectly well on my (presumably case-insentive) development machine. When I put it up on the server things went awry and for no immediately apparent reason.

  4. someone not as smart as a SW developer Says:
    September 20th, 2007 at 11:06 am

    Hi Michael

    As a non-sw engineer, I also noticed the lowercase/uppercase disparity - which makes me think 1) I hung around you too much, and 2) Rob isn’t that smart… ;-)

    However, one additional observation referring to your comment…

    “Take a look below and see if you can solve the problem. You don’t even have to be a software engineer as long as you can stomach the bizarre appearance of SQL code – it will give you a glimpse of what software developers face everyday as they stare into their screens. If you ever wondered why engineers give you that glazed look when you ask them a simple question, it’s because they have a head full of stuff like this. So go easy on ‘em.”

    Is it not SW developers who wrote the SQL code in the first place? Is your point that SW developers are inconsistent and non-standards based in their programming? So is the real issue that SW developers need a course on writing user friendly SW? If so, who teaches this, and what format is it in?

    (bet this sparked some fury!)

    If you were a carpenter hammering together the frame for a house, and a fellow carpenter handed you a shovel, what would you do….

    (adding fuel to the fire!)

    JuSt. A - tHou#GhT aS m-EY^e heD nOww HU`rtZ fRuM Th+E pUZEl…. (hard to read without a standard eh?)

  5. Michael Says:
    September 21st, 2007 at 2:53 pm

    >>> Is it not SW developers who wrote the SQL code in the first place?

    It was me who wrote the code so I can only ‘blame’ myself. Except for the fact that the MySQL running on my host server somehow was case sensitive. So that’s where the hammer turned into a shovel.

    It’s interesting that you (Shaun, a highly intelligent person) picked the descriptive label ’someone not as smart as a SW developer’. I think my point in this post - besides having a bit of fun - is to illustrate the particular kind of intelligence that is required to build software. It’s different from end user intelligence(s) or even UI designer intelligence.

    You mentioned standards. I think standards ultimately boil down to ‘forms’ or agreed methods of communicating information. This in turn leads to issues of content and the form/content thing is a big topic in itself that I think I’ll get into in the future.

    Thanks for bringing it up.

Comments

Number of Visits: