Thursday, April 03, 2008

steve-wof My buddy Steve was on Wheel of Fortune last night. The actual taping of the show was a few weeks ago and he was pretty tight lipped about it.

He said he won enough money to pay for the flight out there, so he was happy, err... I mean Happy! He did outstanding on the show and his wife came up afterwards to give him a hug. He won over $80K and a trip to Thailand! Congrats!

fun
Thursday, April 03, 2008 7:22:27 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, March 23, 2008

I spent a little too long on this rainy Sunday afternoon tripping over myself. I'm using the SqlDataSource and the FormView controls in a quick prototype. I clicked the "Use optimistic concurrency" field in the SqlDataSource configuration page so it would compare the original values before updating the database.

I was going along fine when I realized the updates didn't work, but the insert was OK. After several repeated attempts with zero rows updates, I fired up the SQL Profiler and saw my update query right there, plain as day. Why wasn't the update working?

sql-profiler

I even grabbed the SQL out of SQL Profiler and ran it through Query Analyzer - and then bam! I could see it on my screen. The milliseconds for the date time fields were all set to zero, and the actual values in the database were non-zero values. Who was loosing the milliseconds?

Finally, it hit me. I was losing the data.

I was trying to be real smart about setting the hidden "Created" and "Modified" DateTime fields during the updating event of the SqlDataSource control. I would do a similar assignment during the update event for just the "Modified" DateTime field.

protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}

As I was peering at this method, it struck me that I was inadvertently setting the fields to a value that was too granular for my SqlDataSource object. It wasn't passing back the millisecond value, so I compensated by making sure the value is always zero milliseconds, like so:

protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;
   now = now.AddMilliseconds(1000 - now.Millisecond);

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}

With this adjustment, my inserts and updates are playing nicely. Yay!

So, now that i works, I'm still not real happy with it. I'd much rather have the code check a single timestamp column named "Version" than see all that bloat in there.

Sunday, March 23, 2008 5:30:47 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, March 19, 2008

I've been trying to disable script using the IE Developer Toolbar for a while now. Well, at least I've wanted to for a while, but its was greyed out so I couldn't select it in the menu. Its a fine little menu, with "Disable" well placed between "Find" and "View", then when you click the Disable item from the menu, three options pop up: Script, Popup Blocker, and All CSS.

The All Css menu item worked fine, it would drop any styles applied to the page and show me the raw, unstyled HTML content. Yet for some reason the top two items were disabled.

I poured myself a fresh cup of coffee from the French Press sitting on my desk and thunk about it real hard. Then, I opened Internet Explorer, clicked Tools, Options and then navigated to the Advanced tab. Sure enough, the Disable Script Debugging options were selected.

internet-options

I cleared the checkbox and restarted IE. Low and behold, I could now disable the JavaScript because it was no longer greyed out in the IE developer toolbar.

ie-disable-script

Drat!

ie7
Wednesday, March 19, 2008 7:53:34 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, March 04, 2008

Not because we want to and not because its better, but because its in accordance with regulations written by the Federal Communications Commission. Right. Don't mention anything about that big cluster of wires that branch off into that secured room ran by people who don't work there. Stick to the 'better protect' copy.

comcast fcc security message

The image above is what I got when I logged into my Comcast cable account to find out how much last month's damage was. I'm not really digging the sites that say, ok, you've authenticated with a username and password, but it looks like you're on a different computer or different IP address, so I'm going to add one more thing you need to remember and type in. Isn't agility what the web is all about? I know there's a balance to strike, but we aren't there yet. Where's that damn CardSpace and OpenID?

Tuesday, March 04, 2008 10:14:21 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Saturday, February 23, 2008

As The Wife probably knows more than most, I read a lot of books. That is, books about technology, mind you. I think I took a SQL Server 2000 book on my honeymoon. The Wife reads more (approximately 2.5 vertical feet of books per month) than I do, but she's all over the chart with bios, mysteries, thrillers, oddities like a book about the number zero or salt; even those sappy romance books.

I'm currently reading what could be a really interesting tech book but I feel more like a proof reader. I'm not saying I'm like Chris Sells or anything with my own book, I've got some errata. However, this book I'm reading now has ascended the six stages of book errors with invalid code and sentence struggles in short order:

  1. Whoops
  2. Laughter (with)
  3. Laughter (at)
  4. The 'oh crap' stage
  5. Can I learn anything here?
  6. Is this book actually hurting my brain?

I've never seen one this bad before. It really makes me appreciate the great editors that I was fortunate enough to have on my team. This is more of a reminder to myself - for gosh sakes, proof your work before you send it out! Gah!

Footnote - any grammar issues in this post were purely intentional.

Saturday, February 23, 2008 9:50:37 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, February 18, 2008

When I was 8 to 12, I was big into Dungeons & Dragons. My brother was five years older, and sometimes I could sit with his friends and play. We had all the books, much to the chagrin of my parents. When the D&D cartoon came on, all other things ceased to exist for those short 30 minute chunks of time.

Start-Up Junkies Now that I'm older, I watch a new show called Start-Up Junkies, its on the MOJO channel. I first heard about the show at my local .Net User Group meeting. The PADNUG organization gets together about once a month, sponsors buy pizza and someone presents for 60-90 minutes on a .Net related topic; recruiters abound here. Being so close to Redmond, we're a little spoiled with lots of juggernaut speakers around. At the last meeting, Matt Davis gave what was arguably one of the best sessions I've ever seen here. He's a relaxed speaker and clearly an expert in his craft.

Matt works for a company called Earth Class Mail, a start-up with a great idea. They offer a mail processing service. When you sign up, you change your address and send your mail to them. They scan all of your mail and you access it online. They can scan just the outside of the envelope or open and scan all of the contents too. You can shred it or have the physical document sent to you if you want to keep it. The company was growing at a reasonable pace when they signed on the mysterious giant corporate client, code-named "cheetah". If they make this pilot project with cheetah work, they'll be huge. Matt mentioned the TV show in passing during the presentation and I looked it up.

Start-Up Junkies follows the company through the frantic pace of trying to scale up without failing. I saw the .com bubble rise and fall so I really get this show. The cameras wander all over the offices, covering the CEO, marketing, sales, I.T. and operations. Sometimes I'm cheering and other times I'm yelling and the screen and shouting WTF!?!?!

I love my job and now I get to watch a little bit of it portrayed on HDTV. Watching in the one-piece jammies with feet is optional.

Monday, February 18, 2008 9:44:13 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, February 15, 2008

One of my teammates recently had a problem with some Flash injection code. She was setting some properties and then calling a function on a JavaScript object that threw an error. We got a message that said "Object doesn't support this property or method".

 Object doesn't support this property or method

We isolated it down to a timing issue by dropping an alert() into the code just before we called the method. With the alert() pausing execution for a few seconds, the browser had enough time to fully instantiate our object. Without the alert(), the method was called before it was built. Its a problem that can make your brain hurt.

Here's how you can test for the existence of a JavaScript method before you call it. You might need to do this if you're working with asynchronous calls or dynamic objects that take a while to build.

I created a sample page to demonstrate the issue and how to deal with it. I put three hyperlinks on the page that each call a JavaScript method. Here's the JavaScript code.

Testing for a JavaScript method

At the bottom of the previous code block, you'll see some JavaScript in the mainline section. This code gets executed as soon as the browser sees it. JavaScript is an interpreted language and the browser processes it in a top-down fashion. So, by definition, the browser already knows about my three methods before it runs my code in the mainline.  This is where I define an empty object to test and then create an instance of that object. Just two lines, not much so far.

When I click the link that runs the function named TestForFunction(), I perform some due diligence tests by checking for an undefined object as well as a null object. The last test with the arrow pointing to it is the key part. This will tell me if the method exists without actually running the method. I show one of two messages based on the existence of the method.

The top function named CreateFunction() just spot welds a method onto my object. Even though I've already created an instance of my object, I can still see this method in my instance because I've added the method to the prototype. When this function returns, I've got my new method. When I run TestForFUnction() again, it will see the method.

The bottom method just executes the function I added on the fly. When my DoWork() method fires, it shows a message in the alert() pop-up.

If you find that you need to deal with this type of problem in your code, inspect the object for the method before you call it. If the method doesn't exist, refactor your code to call the window.setTimeout() function for a few milliseconds and check again. Once it exists, your code can continue executing.

asp.net | ie7
Friday, February 15, 2008 10:54:22 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, February 13, 2008

I was on a call with a former colleague discussing a specific technology and how it applied to his situation. It was good to catch up again with him and give some useful advice. I fielded several questions about the flexibility, complexity and fitness.

During the call, I had a thought that really stuck with me:

We (read: the world) are currently in the fifth version of the Microsoft .Net Framework, we have more AJAX libraries than you can shake a stick at, SQL Server 2008 is launching soon, and I still haven’t finished pulling tricks out of SQL Server 2005. There’s not much outside of our reach. We can customize nearly anything and change most behaviors to suite your taste. I can override methods, inject JavaScript, and execute complex database activities in just a few LINQ methods.

But… should he do this to the platform? The word “could” and “should” really stood out for me.


Tis this desire of bending all things to our own purposes which turns them into confusion and is the chief source of every error in our lives.
— Sarah Fielding (1710–1768)

The answer to his specific question was a resounding yes. It was absolutely possible to do brand those pages. I was positive that my former colleague’s team could build a custom external application to manipulate the database and perform the same types of functions that come with the default installation of the system; albeit through their own unique user interface.

In this call, I was asked about completely customizing the administrative pages. My first instinct was to identify which way the cost/benefit ratio tipped.

  1. Could the customer use the money elsewhere and yield more benefit?
  2. Does this preclude the platform from future upgrades because of egregious customizations?
  3. How many people would be subjected to these administrative pages?
  4. How often are they used?
  5. Does he want to support this code? One reason to buy a platform leverages on-going support and bug fixes; this path has the potential to give away that important strategic advantage.

Once a technology is chosen (no small endeavor), the best approach is to deeply understand what a platform does well and make damn sure you’re embracing it. Don’t spend valuable time fighting technology in lieu of focusing on your business. If you’re not leveraging what the platform does best, you’ve got a good sign that you’re off course or you’ve chosen the wrong platform. Go figure out which one it is and fix it – fast!

Wednesday, February 13, 2008 4:54:55 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |