Monthly Archives: September 2008

Will make you lazy?

Don’t get me wrong. I LOVE I have my beta badge. The very first question I posted was answered in under 40 seconds. You cannot beat that! stackoverflow is a GREAT tool that will help you learn and work better. I wish we had something like this a long time ago. And I am EVER grateful to Jeff Atwood for granting me permission to use his excellent blog posts in my podcast.

My question stems from my interest in the workings of the human brain and human nature. Early in my career, often times when I ran into a programming roadblock, I would run to the senior developers and they would help me resolve the issue. On one such run-to-senior occasion, none of the seniors devs was available. Came back to my desk and 10 minutes later I resolved the issue. That lack of easy access to a ready solution forced me to “think-out-of-the-box” and solve the problem.

Will easy access to which has no barrier to entry (no logins to create, no registration, just ask away) make you lazy? Instead of spending that extra 10 minutes, will you just post a question and wait for answers? Granted you have to know when to stop endlessly spinning the wheel and ask for help, but you also have to realize that it is better to learn to fish than just go get the fish. But then, you also use google to search for a solution to a problem. Often I have pasted the error message in the search box and gotten a good solution. Does that make you lazy? Not really. But stackoverflow is different. There are these answer trolls sitting around answering questions. At least that’s what it looks like. The number of unanswered questions, whenever I have looked, has stayed below 100. The goal of stackoverflow is to eventually have the answers popup via a google search for the question.

Good developers will always know when to stop and ask for help. I think the voting feature built into stackoverflow, especially the ability to down vote a question, will eventually weed out silly questions. And, as developers wishing to move beyond 5:01 one should resist the urge to post every question on stackoverflow. You may argue that you are learning from others’ answers but answering a question is a better way to learn and will help you build your reputation.

To answer my own question, No stackoverflow will not make you lazy. The lazy, average 5:01 devs will always be lazy. Let’s make stackoverflow a great resource.

Now, go answer those few unanswered questions.

kick it on


Collections in .Net

Recently, I was asked “What are the various kinds of collections in .Net. And when do you use them?”

From the top my head I could recount Arrays, Lists, Linked Lists, Queues, Stacks and, completely forgot about dictionaries. All of these are collections of items of some kind. You can loop over the items and do something with each of them. But then why do you need so many kinds of collections? When is it appropriate to use a type and, more importantly, when is it not? These two are very important questions that determine the appropriateness of a collections types use.

Like most, well I would say everything, in software engineering – IT DEPENDS. Depends on what? Depends on what the purpose is. What is that you are trying to do? What is the problem you are trying to solve?

Arrays, for example, are allocated from a contiguous chunk of memory. If the process cannot find the required amount of contiguous space, a garbage collection might be triggered. And this will suspend the current tasks. I will not go into the details of garbage collector and the process of garbage collection here. Just pick up Jeffrey Richter’s CLR via C# for a very thorough treatment of the subject.

Items for lists, say for example linked lists, may be allocated on the heap and the appripriate pointers adjusted. This probably is a fast process but the entire list may be fragmented and when looping over the list items may present a performance degradation. I haven’t done any tests but this is my conjecture from reading up on the types.

So, you need to be cognizant of what exactly happens when you use a certain collection type and what your requirement is. If your solution involves copying lists t(I don’t mean the list item, but a list of items) to another and doing something with it, an array may not be an appropriate type to use because, chunks of memory are allocated, chunks that may need to be garbage collected if Gen0 is full.

The collection type you use is also determined by –

1. Do you want index based access?

2. Do you want to store the same type in your list type or are you going to store different types?

3. Does looping over items in your list result in boxing and unboxing of types in the list?

4. Do you want name/value pairs?

5. Do you want a First In First Out or Last In Last Out type of access?

So there you have it. I have attempted to provide a very high level view of some the collection types in .Net and when is it appropriate to use a given type.

Feedback welcome.

kick it on

SQL Server 2005 SP2 KB948108 – Failed install

For the past few days this Security Update for SQL Server 2005 with SP2 kept nagging me via Windows update on my windows XP SP2 machine at work. Couple of times, I did try installing it and the installation completed without any apparent errors. But a few minutes later the Windows update nag would show up again. I downloaded the KB from Microsoft and tried a manual installation. After 5 minutes the message “No qualifying product installed on this machine” popped up. 5 minutes later the nag message popped up. I had disabled couple of ununsed services like Analysis and reporting, enabled those. Still no luck.

I had resisted upgrading to Windows XP SP3. Finally I relented and installed SP3 and then the KB and that took care of the nag. The KB installed without any errors although it did take a while (more than 20 minutes) to complete.

Hope this helps someone.