Archive for the ‘solid code’ Category

>Fail At Once

October 19th, 2007

>This message will be repeated in english.

Automatiska tester i all ära men hade det inte varit bättre om man inte hade behövt testa alls?

Jag kommer komma tillbaka i ämnet.

Automatic tests are great but hadn’t it been better if one didn’t have to test at all?

I will get back on the subject.

>Find the cause of the error

October 18th, 2007

>This message will be repeated in english.

Häromdagen dök en konstig sak upp i testningen. Fel uppstod och försvann utan att vi gjorde något. Jag bygger system så att detta inte skall hända så det var dubbelt konstigt.

Jag satt med testaren på telefon och diskuterade vad han gjort och vad vi andra gjort; om något hänt mellan eller under hans tester. Vi diskuterade databaser, releaser, maskiner, applikationer, var han hämtar… Bingo! Testaren förutsatte att en installation var kompilerad innan han testade.
I efterhand kunde jag ha listat ut det eftersom jag var med och satte upp QA-reglerna men i min iver att få ihop den nya funktionaliteten och testa att leverera utan att testa glömde jag av testarens arbetsregler.

Så vi hittade felet; fel målbild. Målet var inte att ordna med ny funktionalitet utan att levererera denna nya funktionalitet till testaren.

The other day a wierd thing surfaced in testing. Errors sprung to life and disappeared without us changing anything. Considering me constructing systems so this will not happen made it double wierd.

I disussed this with the tester over phone. We discussed what he had done, what the others did; if something happened between or during his tests. We discussed databases, releases, machines, applications, where he fetches… Bingo! The tester fetched each new ready created installation and I hadn’t supplied one.
Looking back I can know I knew I had to create the installation before handing over the new functionality; but eager to deliver and try to deliver without testing made me forget the environment of the tester.

So we found the error; the wrong target. The target was not to provide new functionality but to deliver this to a tester.

>Managing versions of a database

September 21st, 2007

>There are in SQLServer2005 ways to version control it through tools by Microsoft. Since I havn’t had the time to learn how to and some of us use other databases there is a common technique that works so so but at least gives us a chance of reverting to an older version.

Any time I decide that this is version x.y. I check in the database as binary. Image or backup doesn’t matter as long as it is recreateable without anything else.
After that all updates must be scripted. These scripts are checked in in the same folder as the database.
One can then get the database and use the date stamps on the scripts to get the exact version of the database.

After a while there are too many scripts so we check in the database again.

One then sorts the files on date and starts by getting the database. Then run the scripts to the proper version.

This is not a perfect way; it is easy to forget to script a change. But it is a start at least.

>! is a bad operator

September 13th, 2007

>In C#, C and C++ the exclamation sign (!) is used for negating a boolean value.

This is considered a bad thing because it is so small and easy to miss.

    if( !IsPostBack ){…

I would like to write

    if( Not( IsPostBack ) ){…

instead.  But I have yet to find a way to overload it such in C#.

Even with the improved readability of “Not” it is easy to think wrong.  It is way too easy to get lost in negations in a just slighty complex boolean expression.

A way to improve readability is to avoid the useage of ! or negations at all:
    if( IsPostBack ){
        // Does nothing.
    }else{
        …
    }