Saturday, 29 January 2011

GUIDe me

Joel Spolsky in his article Lord Palmerston on Programming wrote:
We live with a hockey stick learning curve: you can learn 90% of what you use day by day with a week of learning. But the other 10% might take you a couple of years catching up. That's where the really experienced programmers will shine over the people who say "whatever you want me to do, I can just pick up the book and learn how to do it."
At one of my previous jobs there was one guy who once asked this: "What would be if some day you get the same GUID generated by NEWID() function?". That would be a disaster, actually. That's how the apocalypse begins, if you ask me. We fired him. Of course, not because of this question.

He was not stupid. Actually, he was smart. He was just like that - knew the basics and could code anything after picking up the book and learning how to do it - in theory. In practice, he might end up with just a couple of lines of code in a whole day - simply because EVERY line of code required him to pick a dozen of books.

Somehow I feel like this digging into ASP.NET. I can explain how it works in two minutes, but I have to answer a millions of questions every time I want to solve a simpliest task. Should I use any type of container to put my controls into? Should I create my custom control or just put a group of separate controls on the page? Should I write JavaScript code calling a Web service to update my page, or just use asp:UpdatePanel control? Does asp:RadioButton trigger a postback when checked? Should I make text bold using the control property or using the new CSS class? May I get rich text editor out-of-box?

To finish with the GUIDs: there is one good reason not to build clustered indexes on GUID fields: since GUIDs are usually generated in non-sequential order, it is very likely to cause a page split when inserting a new data into the table. Well, this one can be answered now by using NEWSEQUENTIALID() instead NEWID(), which creates a GUID that is greater than any GUID previously generated on a specified computer since Windows has started (not to forget, this is a potential security issue). Anyway, the bigger is the index field, the more space it takes on the index pages in B-tree, the less effective is the index, so, generally speaking, you'd be better off GUIDs, still, if you have a choice.

No comments:

Post a Comment