Give Your Manager A 500% Productivity Enhancement

Easy. Replace his homepage with a small chunk of html that says:


Requested resource:
THE INTERNET
is currently locked by another user.



You cannot access this resource
until the current user has finished
performing read action.




Download your own copy here: locking_error.htm

But be prepared to handle the increased workload as the pointy haired boss assigns you more than the usual number of database re-paints per metric furlong.

 

In Vista, final step of installation launches YOU!!

I learnt from NagarSoft that the security conscious Vista doesn't like the idea of an installer that has a 'Run Program Immediately After Installation' step at the end.

This is because "Any processes Setup spawns will inherit the same privileges as Setup" (from Inno Setup Knowledge Base, FAQ Vista)

Okay well this is sad.

An A+ For Security! But An F for Usability!

(continues...)

I mean I get the technical side of it: the setup process needs to have elevated privileges to perform the installation. But you don't want the application itself to have those privileges.

But look at the human side of it: you download something off the internet, and install it. You then have to go hunting around before running it.

That's sad.

The average attention span is now resting at around 5 milliseconds. If you can't find a way to launch the application at the end of installation a lot of users are simply never going to get around to using the software they've installed.

It ought to be easy for developers to provide the features users use.

Actually, looking at the 'technical' side again, this is not just a problem for installation software. It's a common siutation. Say I've written a code editor, and I want to allow the user to launch other tools from this code editor (e.g. 'Preview in Mozilla'). The tools won't be fully trusted by the code editor. When I launch such a process, I'll want to give it the lowest privileges I can, regardless of whether or not I'm an administrator.

I'm basing my opinion on an article at TweakUAC that says:

"Microsoft has... for some reason... not offered a similarly easy way of start[ing] a non-elevated process from an elevated one."

That article provides a Visual Studio 2005 project that shows how an administrative process can launch a process as a standard user. I haven't tried it myself: but it don't look easy.

(All found thanks to the daily grind)

See also Russian Reversal

 

The Macho School Of Programming

tdd,
A very macho programmer

If you've got time to write comments -- you've got time to refactor.

If you've got time to refactor, you've got time to write unit tests.

If you've got time to write unit tests, you've got time to redesign the system.

If you've got time to redesign, you've got time to drink.

Have a beer. Comments are for sissies.

(todo: insert picture of a geek with a big macho moustache)

(modified image from epica-awards.org)

 

The Project Never Ends

What's the expected completion date for your project? And is that really the end?

Projects never end. This only just occurred to me: projects never end.

Whatever project you're doing -- the end is just the beginning.

Launching a website... maybe it's the beginning of a new business.

Tearing down an old building -- something will be built in its place.

Planning a wedding -- that's just the start of the marriage.

Planning for the birth of a child... is the project over once the tyke is born? (congrats to s&p, by the way ;-))

Dethroning the dictator of a country... sounds like the beginning of a new era, not just the end of an old one.

Maybe your involvement with one project will end and you'll move on to work on others. But the work never stops, the projects never end.

I'm exhausted just thinking about it.

Good luck in all your projects.

 

The TDS RPC is FUBAR? You don't say.

I just got this message in an exception...

"The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 5 ("@Amount"): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision."

Turned out I'd divided by zero, and attempted to send the result to a stored procedure.

Such a peculiar error message: by turns cryptic, descriptive, informative. Just thought I'd share it. ;-)

 

Gunderloy, Spolsky, Atwood: three big idiots.

[disclaimer: i'm a big fan of these three people, so much so that i'd take the time to criticise them publicly ;-) ]

In which I attempt to demonstrate that three of my heroes are indeed fallible human beings. And rather than do the nice decent thing and write to them privately, I insult them publicly for the GOAM (er, Good Of All Mankind).

Gunderloy -- idiot? Why?

In a stunning, yet well-telegraphed, event, Mike Gunderloy -- author of the Daily Grind -- has quietly drifted away from the warm embrace of the borg collective, er Microsoft, and decided to re-start his career in the Linux world. Go and check out his new blog, 'A Fresh Cup' for some news and background on this move.

The good news for microsoft consumers like myself is that Mike will continue to publish the Daily Grind for the foreseeable future.

But what's going on?

As long as i've been following Mike's writing he's been very critical of microsoft, cynical about Longhorn/Vista and very under-whelmed by office 2007. The cynicism was pretty powerful at times (hey that was always my favourite part!) and boiled a little hotter than usual lately when he attacked the office ribbon licensing scheme.

I think that in the last few years there are two sides to microsoft. We see these two sides continually.

(continues)

It's not "Raymond Chen versus MSDN" as spolsky would have you believe -- but more "Obasanjo versus Ballmer". There's the open, sharing, blogging, all-too-honest world of Dare Obasanjo -- the kind of world that Robert Scoble deserves a lot of credit for (even if you do see him as the blogging-equivalent of a hyperactive, ginger-haired tap-dancing 10-year-old). On the other hand there's the Steve Ballmer, business rationalist world, with it's licensing schemes, its cautiousness, bullying, monopolies, and general machiavellian attitude. Each side genuinely believes it's The Real Microsoft. And i think that for Mike G, the Robert Scoble picture of microsoft was always a flimsy illusion, just a facade that covered the true, cold-hearted, evil nature of the beast.

(at this point i want to insert a quote from an old issue of the daily grind where he said that he believes the openness of microsoft will come crashing down once someone stuffs up in an unapproved blog post and causes too much trouble).

On the surface, his decision to switch to microsoft has been prompted by the licensing scheme for the office ribbon ui. Clearly, it's mired in deeper difficulties. The complexity of moving to Vista gives a person time to stop and ask why -- why move to vista? if it's going to mean so much new learning, couldn't the same overall effort allow you to switch to a different OS?

And i think Mike, like all of us -- perhaps more so because of the even higher pressure he places on himself -- feels overwhelmed by the huge volume of learning that is required in microsoft technologies, just to keep up. He's mentioned the Red Queen's race before, and boy do these words strike home for anyone who tries to stay abreast of the latest microsoft technlogies:

Does this make him an idiot?

No, never. The guy's a genius. I just thought a provocative title would help. I think that in a worst case scenario, he'll return to the collective in time, hopefully with his cynicism sharpened even more, with extra experience he's willing to share with us, about what can be done better and other lessons from other worlds.

In a best case scenario, he'll find an exciting new career in the open source world, and help more of us to make the move.

Somehow I can't help but hum the tune from the "Hitch Hiker's Guide to the Galaxy" movie... 'so long and thanks for all the fish!'

Spolsky -- idiot? Why?

Well that Joel Spolsky really is an idiot. ;-)

Okay, before I savage another one of my heroes, here's a little side story. Situations have recently meant that I had to try and use a bug tracking application other than Fog Bugz. Oh god, how much I miss my Foggies! Joel takes usability seriously, and for that we salute him.

But what's going on?

Joel wrote an article lately picking on the design of the shutdown options in Vista. His article called for a drastic simplification of the shutdown scheme. Hey I kind of agree, but I also saw big holes in his argument, which were conveniently described already at suniltana.com.

None of this makes him an idiot, though. What annoys me is that a recent article, Simplicity (arguing against simplicity, in favour of adding new features where needed) was clearly a contradiction to his earlier article. The contradiction/hypocrisy was so glaringly obvious that I can't help but think that Joel has done this deliberately to try and cause some controversy. I think he really wanted people to spot the hypocrisy and pick him up on it: it was so obvious and yet he didn't mention it.

If this was the plan, then it mis-fired, as complex plans do, and the readers tended not to pick him up for the hypocrisy at all (it's not like he was insulting Ruby On Rails) and instead just nodded and said 'okay, we believe you Joel.'.

His most recent article, about Elegance, nicely intermeshes these two apparently contradictory ideas (choices versus simplicity) but I still left feeling a little cheated. It seemed a little more contrived than I'd like.

Atwood -- idiot? Why?

Aw, maybe you ought to love Jeff Atwood (from Coding Horror.

Three great points about Jeff:

  1. When Hanselman has computer problems, he calls Jeff. And Jeff solves them. That's a pretty amazing talent right there.
  2. He's sent a lot of traffic to this blog! Thank you Jeff!
  3. He's in favour of supporting small ISV's! A great initiative. My early money is on Html-kit, and a few others are on the radar.

But what's going on?

The little thing that has annoyed me about Jeff is that sometimes he's slow to give credit. Recently he quoted almost all of an article by my compatriot Jo Cooney, and he hardly credited Joseph at all.

As a result there were 183 comments at Jeff's site, and only 5 at Jo's. I think this was partially a symptom of the poor credit-giving.

Another example was a very funny cartoon that Jeff used a few months ago, in his article Meet the Arch-Nemesis of Productivity: The Internet. Initially he gave no credit for this cartoon, and a lot of readers assumed he'd written it himself. Eventually he did give link the picture to the source and give a reference. His excuse was that he'd saved the picture some time ago and lost the source. Fair enough, but he's got some journalistic background and should've known better.

In fact this wouldn't normally annoy me even one little bit. But Jeff is the world expert at linking to his own content. He will never *ever* miss an opportunity to link to his own back catalog of work. So why shouldn't he be just as quick to link out to other people? (I've followed his lead lately, and started linking to my own back catalog more... it seems like the right thing to do.)

Jeff's only other 'crime' was his article 'Has Joel Spolsky Junmped the Shark' in which I thought the accompanying graphic was just outright cruel.

What's the lesson here?

I'm keen to see Jeff keep up the helpful content and the excellent writing. Just want to see him be a little quicker to link out to some of his sources. I think it's better to err on the side of over-linking rather than under-linking.

Well, that's enough iconoclasticism for now.

Have fun! No harm meant.

 

Deadlocks: What would Feynman do?

deadlock info from trace 1204

When confronted with a difficult situation, I often ask myself "What would Feynman do?"

And I know that Richard Feynman, apart from being a brilliant theoretical physicist, gifted lecturer, writer, problem solver, great mind of our age, and all-round wise-guy, was also a bongo player. I don't personally own a set of bongos, but i do have a large swiss ball -- so i took to sitting on a computer chair, with the swiss ball between my knees, beating out a funky congo rhythm using two heavy winter socks as drum sticks. Just Like Feynman.

The problem at hand was deadlocking. Boom ba-da-boom. One little deadlock can ruin your whole highly-concurrent service-oriented-architecture. Boom ba-da-boom.

Deadlocks are easy to fix once you know the cause and you have the solution and it's all wrapped up and you're looking back on it later, preferably with a Singapore Sling in one hand, and an elbow propped on a bar. Listening to some groovy jazz. Tapping your foot, and smiling. Oh, there's nothing easier to fix than a deadlock. Once it's fixed.

(continues, with mystery solved)

But prior to that, a deadlock is a crushing, debilitating, nasty, ugly, painful, evil little problem. Out of the box, SQL Server gives you no help at all. The best you get is a message saying 'hey, there was a deadlock, and a particular statement was chosen as the victim'. That's it. Turning to google, I soon found some great articles from Bart Duncan: Deadlock Troubleshooting.

It turns out that you can ask for more information, by turning on particular options ("DBCC TRACEON (1204, -1)" in SQL 2000, or 1222 in SQL 2005). My deadlocking issues were in SQL 2000, so i had to use option 1204 -- and option 1204 gives you a very obfuscated little message, here's what I got:

info produced by option 1204

So this turned out to be one of the simpler deadlock scenarios -- where two instances of the same stored procedure are blocking each other. How obfuscated can an error message be!

The highlighted parts of the image tell the story:

  • There was a deadlock between process 170 and 173, with 173 chosen as the victim. (this is told by the red highlighting)
  • Both 170 and 173 were trying to execute line 22 of of the sproc, "MessageLog_SelectedRelatedQueuedItems" (this is the green boxes)
  • Both processes already had an "IX" (intent exclusive) lock on the "MessageLog" table (this is explained by "TAB: 18:834818036." see below)
  • Both processes wanted to upgrade from an 'intent exclusive' lock to an actual 'eXclusive' lock. But neither process could, because of the IX lock held by the other process.

The most important parts of the message are the hardest parts to find. In particular the 'X' and the 'IX' were crucial here.

First: why does "TAB: 18:834818036." mean 'the message log table'?

Because we look at those two numbers, 18 and 834818036, and we do the following (in query analyzer):

Use master
Select * from SysDatabases where ID = 18

this returned a particular database... let's say it was called the "Message_dev" database. I performed the following:

use Message_dev

Select * from SysObjects where ID = 834818036

This returned the MessageLog table

So it's the table itself that the lock is requested on, as opposed to an index or a view, for example.

Exclusive Locks... Intent Exclusive Locks... Could you dummy it down a shade?

Look I try not to think about this stuff too much. When everything is working fine, you never have to worry about what kind of locking strategy is being used under the covers. But when deadlocks occur you suddenly want to understand everything at a very fine level of detail.

Rather than try to understand it completely from scratch, I did what every good programmer would do, and googled for an answer. The incredible Itzik Ben-Gan had helped someone with this exact problem before, so I'll quote his description:

"Technically the deadlock happens because each transaction first acquires an Intent Exclusive lock (IX) on the table and keeps it.

Typically an IX lock indicates the intent to modify rows at a lower granularity level.

Then the transaction attempts to acquire an Exclusive table lock (X); I believe that it attempts to acquire an X table lock and not go through Intent Update (IU) and Update (U) locks first because you requested to work with a serializable isolation level, and since there's no index, the way to guaranty serializable is to lock the whole table.

An IX lock is compatible with an IX lock, therefore two different transactions can acquire IX locks at the same time. But an X lock is incompatible with an IX lock, so when the timing is such that both transactions managed to acquire IX locks and then ask for an X lock, they're blocking eachother and you have your deadlock.

if you add a TABLOCKX hint, you tell SQL Server that you want to exclusively lock the whole table to begin with, so there was no need for IX locks, hence no deadlocks.

Also, The deadlock doesn't happen in read committed isolation because the transaction requests the following sequence of locks:

1. IX table
2. IU page
3. U row
4. IX page
4. X row

The key in the deadlock prevention here is that U lock is incompatible with U lock (not with previously acquired locks) so one transaction blocks the other as opposed to both blocking eachother.

So a couple of ways around the deadlocks are:
1. Use the hint
2. Use read committed isolation

A third option that I tested that seems to work is to create a clustered index on the other column. I have to start class so I can't check the sequence of lock requests that helps preventing the deadlock... I'll leave it to you... ;-)"

(see, original message here)

Okay -- i followed Ben's advice and I soon got there. I didn't use the table hint he suggested, as locking the entire table seemed like overkill. I was able to change the isolation level to read-committed. After running a lot more load-tests on the server, the deadlock didn't re-occur, so we were happy with the solution.

One thing I'm left wondering -- is there a way that SQL server will tell me what locks were applied for a given query? So I don't have to try and calculate it myself, with the margin for error/incompleteness this entails?

In any case, this was perhaps the second nastiest problem I've dealt with this year, and I thought I ought to record it somehow. Once I understood the problem fully it seemed strange that I don't hit this kind of problem more often. The fact that it only occurs under highly concurrent situations might be the only saving grace.

Anyway, time to get back to playing those drums. Bring it on Feynman.

 

Hey idiot, I've got toothache. BOO!

Horse walks into bar, barkeep says 'Why the long face?' Now laugh or I might poke you in the eye, my pretty little kitten.

What's all this about then? Kathy Sierra says you should begin your talk/book/blog entry in the following ways:

  • Be provocative
  • Evoke empathy
  • Do something surprising... VERY surprising
  • Start with something funny
  • Promise there will be conflict
  • Start with a dramatic key event or turning point
  • Mystery, suspense, intrigue
  • Deliver an emotional experience

Just checking if doing all of those things at once is extra effective. ;-)

(continues)

Kathy goes on to suggest you needn't begin in these common ways:

  • Don't start at the beginning!
  • Don't Tell (when you could be showing)
  • DO NOT start with history!
  • DO NOT start with pre-reqs
  • and you don't need to establish your credibility up front

All great points. I think you have to know also, that when you're writing something, or planning something -- don't worry about the introduction at first.

You can do that bit last. Failure to realise this is a common cause of writer's block. People sit there (myself included) worrying over the first few words, before anything else has been done. Forget it, just move further in, and come back to that bit.

You can start with a bad version that breaks all the rules, and then edit it in to shape later. Editing is the most important skill in writing. If you're a good enough editor you can edit just about any old crap into shape, provided there's some crap there to begin with.

Okay, enough preaching. Just blog it.

 

And Microsoft has Won

.net borg sphere

You know, I don't really think they lost the api war after all. But I'll get to that in a moment.

Human Interest Back Story

Once upon a time, I was on holiday in Italy and I got trapped talking to a group of girls from New York. All they could talk about was New York, New York (the city so nice, they named it twice). One of them said something like this:

Now, about that war...

And that's how I'm starting to feel about .Net. Why would you ever leave this place?

Maybe you prefer python to C#? so use IronPython.

Maybe you're a command line junky, so stop wasting time with bash and use Powershell.

Maybe you're into functional programming -- so use F#. Oh, you prefer Lisp -- then use L#.

Ruby is hot yeah? So use Use Ruby Clr. Use Ruby.Net. Use Iron Ruby.

You're into 3d dimensional scalable graphics... so ditch flash, use expression, wpf and xaml.

Whatever your poison, we've got it right here.

The underlying .Net platform seems to be flexible enough that it's attracted language designers from all programming disciplines. It's a strange reversal of the 'Microsoft As Borg' meme.

Microsoft has long been compared with the borg. Now I am starting to see it for real:

We will add your language's distinctiveness to our own.

Only there's a twist.

The supposed irony about the borg (in star-trek, at least) is that from their vast collective of culture and technology, they create something so horrible, something less beautiful than any of the cultures they assimilate. So, rather than an increasingly wonderful whole, they achieve utter repugnancy.

By contrast, (and quite suprisingly) I think that the .Net framework has become more beautiful as it has grown. The addition of generics, for example, is a feat of incredible beauty. Anonymous methods are not just some stuck on frankenstein's nightmare: they seem to be the fulfillment of a long line of clever design decisions that carefully moved in the right direction, right from back before there was any 'there' there.

Hang on -- don't flame me yet. I know i've been sinking too much of the MS Kool Aid. I'll wake up tomorrow and the love for microsoft will have dwindled. At the moment i feel pretty lucky that without changing framework I can delve into python, F#, powershell... three very interesting technologies, and without any of that traditional microsoft feel.

About that downside...

On the downside there's been recent suggestions that programmers in the microsoft world just fundamentally don't understand open source development. And there remains the persistent fear that no matter how good your product is, you may turn out to have simply been doing 'market research' for microsoft.

less of the frightening, please

And the latest scary thing from microsoft is the licensing for their ui. Read Mike Gunderloy's rant about it -- but read other opinions too, as it's a tricky topic.

So the borg are kind of... attracting me, wooing me... but still frightening me fairly often. I hope the good things continue, and they learn to do less of the frightening.

Cheers.

Borg Sphere image courtesy of The Model Citizen

 

10 Websites that would Not work as Wikis

Wikis are great, i love wikipedia, ward's wiki, etc. But some stuff just doesn't lend itself to wikification. Here's a sample of '10 Websites that would Not work as Wikis'.

  1. The FBI Most Wanted List
  2. Sports and Betting Results
  3. A stock market/exchange
  4. Google Results
  5. The Guinness Book of World Records
  6. Train and Plane TimeTables
  7. Your National Constitution
  8. Prisoner Release Dates
  9. The 2007 United Stattes Presidential Election Results
  10. An Online banking application

What websites/applications do you know that couldn't (or could) be a wiki?