A few days ago I needed to retrieve the version information of an Winforms application and append it to some files. I needed to do this via a batch script. I did it with the following script:

@echo off
setlocal
for /F "delims=" %%i in (
'findstr /C:"<Assembly: AssemblyFileVersion" 
".\My App\My Project\AssemblyInfo.vb"'
) do set MyAppVersion=%%i
set MyAppVersion=%MyAppVersion:~32,-4%
pushd .\MyAppSetup\Release\
move /Y setup.exe setup_v%FCVersion%.exe
move /Y MyAppsetup.msi MyAppsetup_v%FCVersion%.msi
popd
endlocal

Nice, isn’t it?

As a software developer it is important to have good people skills. You have to find out what your users want. You have to communicate with them. If you cannot your are at a disadvantage compared to your peers who can. Your current position is determint by your technical skills only for 15 percent, I read somewhere. The other 85 percent are communication skills. Most of the well paid positions are occupied by people with poor technical skills. But they communicate.

As (almost) all geeks I am a bit autistic. Communication is not my strong suite. You have only to ask my wife. I can tell you she wishes I would communicate. As all wifes do I guess. Anyway it is not hopeless. Even if you are not a natural communication talent you can learn it. ‘How?’, you ask. By reading books about communication and start practicing. Learn form those how can. Most communication skills we all have but we do not use them. We do not use them enough. So read and practice.

I recommend the books from Dale Carnegie. They are easy to read and full of practical principals. Some of his books are How to Win Friends and Influence People, How to Stop Worrying and Start Living and How To Develop Self-Confidence and Influence Others Through Public Speaking.

Last weekend I installed Vista. I tried to upgrade my Windows XP installation. It took al long time, I was stupid and impatient. Yes, I pushed the reset button. I thought that my computer was hanging and expected a reset to continue the upgrade where it left off. But it did not.

The only thing to do was to do a clean installation. So I did. Everything went fine. Since ‘My Documents’ does not exist in Vista I copied the contents of ‘My Docments’ in the new documents location. Then I deleted the ‘My Documents’ directory bypassing the recycle bin. I did not make a backup. Another mistake. Why? There are no documents in Vista’s documents location. How is this possible? I lost important stuff. I do not blame Microsoft or Vista, though. I should have made a backup of my important data!

Is it me or is it hard for users to test applications? No, it is not me. Most developers know what I mean. You need to built in some feature. Ok finally it is working the way you want it. That may not be the way your key user wants it to work. So you tell him/her the feature is finished. Go ahead and test it. You go away and your never hear from them again about the feature. Until it becomes a priority for them of course. Suddenly all kinds of action can be detected from your key user. You are told that something is wrong. He or she is disappointed. ‘This must be fixed. I need it yesterday.’ Right! ‘Didn’t I asked you to test?’, you think. ‘Now I have little time to fix it, damn.’ Sounds familiar? And even if users test it is ad hoc, non structured and not repeatable.

Why is that? I think there are three main reasons for this:

  1. Users do not know how to test. They never were explained how to test so it is not easy for them to do structured testing. They don’t know what to do.
  2. It has no priority. Their other work is more important because that’s the stuff their bosses want them to do.
  3. ‘The developer tested it! why should I do it again’. They forget that a developer is not usually an expert in the field of the user.

 

The solution is to educate them and make it a part of their job. The first thing developers can do. The latter could be done by their bosses. Yeah, wishful thinking…

If you have an application that is used by more than one user and it stores its data in a shared database, you have to deal with concurrent actions of your users on the same data. This means for instance that if two users are updating account information for client X at the same time the application must decide which user’s changes should be stored. There are two models for concurrency: optimistic and pessimistic concurrency.

Optimistic concurrency

With optimistic concurrency no locking mechanisms are used. The idea is that the chances are small that users are editing the same data at the same time. So why bother with an resource expensive mechanism like locking? Because it could happen. An application must have some way of detecting this.

ADO.Net helps a developer out by offering support for the optimistic concurrency model. It tracks changes to data it is updating by including the original data in the where clause of the update statement. If the data was not changed one row was updated, contrary to zero rows updated rows. A DBConcurrencyException is throw in the latter case. A simple but elaborate mechanism.

A disadvantage of optimistic concurrency is that the user that first updates the data wins. All other users loose: maybe they had been working for ten minutes on the data and now they cannot save the changes!

Pessimistic concurrency

Pessimistic concurrency works different. It uses locks to make it impossible for users to change other users data. Of course the idea is that the chance that two or more users are updating the same data is small. So the chances are slim also that the lock bothers other users. But locks do affect scalability.

How can an application support pessimistic concurrency? A developer could implement it him-/herself. ADO.Net does help here. That is a difficult job. What about death locks for instance? Luckily databases help us out. Most databases support different kinds of locking and transactions. For pessimistic concurrency to work however the lock must be sustained for the whole period a user is working on the data. So what happens when this user goes for coffee or goes home. Too bad for everybody else? It is a big disadvantage. Isn’t it?

The conclusion

Looking at the the advances and disadvantages of both concurrency models I think is best to use optimistic concurrency as the main mechanism. Pessimistic concurrency should be used when changes to data must be ACID. But both methods can and generally are used by applications at the same time.