The cost of unit tests

Unit testing is a recurring theme for me these last weeks; between talking about Stackoverflow and other forums and the tests that I write for two ongoing projects, I asked a few questions about the actual cost of the unit tests.

This is especially an article by Thomas Brandt (German: “TDD in der (my) Practice - wish and reality”) that made me think seriously. Brandt describes in his article quite well indeed this gulf between theory and practice of Test Driven Development. Point blank, Rather, it adheres to the principles of TDD;

I must first say that Test Driven Development, especially the principle of "first test", is a rather “sexy” develop. It can certainly improve the software architecture and prevents us from doing certain (small) errors.
— Relatively free translation of about T. Brandt

He therefore considers TDD as a powerful tool – at least from a purely academic. But the immediate result is a doubt;

The question is simply: at what price?

As mentioned, except T. Brandt and I, many other people seem to ask, and the most frequently asked question is as follows: Is that the use of unit tests does she really better software, and is that efforts to invest are they realistic?

Condensed, the question boils down to a simple:

It cost me how much the unit tests?

Often the question involves, that he who raises think unit tests are too expensive to apply consistently. I remember a discussion I had about the value of a total test coverage beyond the theoretical ideal. Reported efforts to provide I said “not” at the time.

As of today I think all these questions are asked simply evil, because it is not know the cost of unit testing is important, more:

How do I pay the omission of unit tests?

And here is my answer, illustrated using a concrete example;

One of my current projects include a large number of distributed components. I discovered an error in the draft, which forced me to refactor both classes. All took me about 1 hour. Launch unit tests? About 30 second. 30 seconds, I discovered that some behaviors were not as originally planned. It took me about 20 minutes for corrections. Writing tests cost me about 45min.
The balance sheet is about two hours.

Without unit tests, I probably would not notice some of the errors immediately. I would have had 1 time refactoring, over a more or less determinable, certainly spread over several days, to correct the problems go unnoticed when changing. The probability that this time goes well beyond an hour is relatively high (debug “hand”, recreate conditions in multi-threaded apps etc.…).

For my part, I find that to calculate a defined time (having tests covering a realistic part of the software – not 100%) more interesting is that navigation in the dark as practiced.

Experiment! ;)

A few NoSQL for MariaDB

Logo de MariaDB

MariaDB a fork of MySQL

A message reached me very happy to MariaDB, the fork very promising MySQL. With a very recent commit in their repository, MariaDB se permet d’assouplir un peux le modèle relationnel classique. With the introduction of dynamic columns (Free translation “Dynamic Column”) the next version (5.3) de MariaDB contiendra donc apparemment un zeste de noSQL!

A primary goal in development was used to make these columns via SQL syntax Classic. De façon interne les colonnes dynamiques sont sauvegardées en tant que BLOB (Binary Large Object).

To illustrate the operation can this new type, a small example:

Select All Code:
INSERT INTO exemple (nom, classe, prix, attributs) VALUES
("HTC Desire Z", "telephone", 420, COLUMN_CREATE(1.5, "Gris")),
("Nokia E7", "telephone", 509, COLUMN_CREATE(32, "noir", 2, "Clavier")),
("Lenovo Thinkpad E420", "ordinateur", 1019, COLUMN_CREATE(1, "noir", 3, "Win7 Pro", "500Go"));

As you can see, everything looks like a query entirely conventional, retail column “attributes” close. In the example, each entry has therefore conventional data, over a field “attributes” which contains a variable number of data (NB: unlike the classical fields, input dynamic array has only one number addressing, mais apparemment les développeurs comptent encore changer ça).

Pour créer une entrée pour la colonne on utilise donc COLUMN_CREATE(), To update or delete an entry must use the COLUMN_ADD() in a normal call UPDATE:

Select All Code:
UPDATE exemple SET attributs=COLUMN_ADD(attributs, 1, "jaune")
  WHERE COLUMN_GET(attributs, 1 AS CHAR(10)) = "noir";

The example also illustrates quite well the use of COLUMN_GET() qui permet d’accéder à un attribut de la colonne. There are also COLUMN_LIST() that returns the list of dynamic columns present.

If you ever want to try this new feature already, jettez on your compiler and repository de MariaDB; binaries will be available with version 5.3 The MariaDB.

Third party components and unit tests

Software Testing - Be a science

Je viens tout juste de lire l’étude Software Integrity Risk Report qui à été réalisée à la demande de Coverity. Broadly the study pretty much sums up a feeling I long ago; le développeur moyen est bien moins soucieux de la qualité d’un logiciel tiers qu’il intègre dans un projet que de la qualité de son propre code.

On the figures, the study says 90% of (330) Developers use third-party sources (they are free of copyright owners or) dans leurs logiciels. Par contre seul environs 40% Developers say these make automated tests on these sources (more cons 75% for sources “home”). It is the same (à quelques pourcents près) for manual testing and integrity (stress-testing/functional-testing).

A certain consensus exists regarding the delays due to poor quality third party code; more 140 développeurs ont répondu qu’une grande partie des retards de lancements ou des rappels étaient dû à des soucis avec des sources tierces.

The final word: TEST! TEST! TEST!

Linux in a browser

Cela faisait longtemps qu’on savais tous que le Javascript n’était pas que là pour valider des formulaires (X)HTML forms and putting some fancy effects on the website. Today M. Fabrice Bellard published a demonstation going beyond what most of us (javascript developpers) could have imagined for years! ’-!

Ce génie a bel et bien réalisé un émulateur x86 en pure javascript! I'll spare you the technical details here (they are readable on Fabrice Bellard's website). Basically, JSLinux is a 486 emulator 486, lacking an FPU and MMX, but owning a complete memory management unit (MMU) complete!

A design feature (allowing that demonstration btw.) is the extensive use of typed arrays (typed arrays specification by the Khronos Group) which have recently become available in modern browsers (Chrome 11 and Firefox4 for now, Opera étant entrain de rattraper le retard si mes informations sont bonnes).

Concerning the linux “distro” installed in the live demo, it is pretty complete; kernel 2.6.20, BusyBox, vi, qEmacs and a C compiler (TinyCC, I did try for the first time =)

Well, I guess you want to discover it by yourself: JSLinux (the page takes a few seconds to load)

Install Mono 2.10 CentOS with YUM

And I'm back with a little Linux tinkering : Install Mono 2.10 on CentOS (5.6 for instance).

Few hours of searching the www always brought to the same result; "build it from source"… and with the nice list of dependencies, that would have been really annoying… so: brain->switch_on();!

Read more

Restore SSL private keys lost!

The experiment’ I am describing today is quite sharp, especially given the topic!

First story: I accidentally erased, or rather, replaced the private key used for SSL encryption on one of my servers. Knowing that without this key the server does walk again once restarted!

What saved me? The fact that Apache loads the entire file into memory! I could have done a dump of the heap / stack process apache2 search…. or look for 2 hours on Google to find the following little tool

Read more

HP Color LaserJet 2600n by W7

Hello everyone; that's the big news; I am now among Windows users 7 (3weeks now) and fairly satisfied. Apart from two small pilot outages (now resolved) nothing wrong, except that the HP Laser printer (CLJ2600n) that is my mother asked me a small rabbit this morning when I wanted to use:

Infact I thought everything was going to work well the first time – it worked on Vista – but apparently the drivers for this network printer is no longer on Windows Update for W7, and HP offers only one version “Plug and Play” on their site (thereby: Support page for the HP 2600n) which is intended to function via USB – at least officially.

Read more

7 Google tricks that can save your life!

Everybody uses Google (with some exceptions…) as a search engine, but who knew that one can use Google to find the definition of a word, convert euros in Bulgarian Levs, or limit the search to information between certain dates?

Some “Cheats” Google, which may well prove useful for!

Read more

jQuery: CSS Transformations animated Opera 10.50

I discovered some time ago transformations CSS first available on WebKit (the rendering engine behind Safari and Google Chrome), was then added Firefox, and most recently with Opera version 10.50.

As always, the implementations are different (let alone Internet Explorer that does not support them at all…) but the script Zachstronaut (a “hotpatch” jQuery infact, adding property transform the function $.css() and rotate and scale to $.Animated()) worked well in Firefox and WebKit…

Unfortunately the implementation of CSS Transformations Opera does not return a value “readable” but a data matrix, for which I have not found documentation. So I took a few detours, and through the function getComputedStyle() I was able to retrieve the necessary to run the animation on Opera.

The amended version of the script is thereby (You will also find an example for those who do not know CSS transformations)., or “how to seek help?”

If you have the misfortune to spend as “geek” (or expert “New Technologies” – to be politically correct) on se retrouve souvent à jouer la Hotline pour les amis et autres connaissances. Most of the time we have left has launched a search engine.

La science "Google"

Science Google"

To help us, people behind LMGTFY, for Let Me Google That For You, have created their site; you enter a search, and the site will generate a “animation” which shows how he must look with Google. You send the link to your friend and you let it learn…

I found a nice idea – Have fun ;)

P.S.: For fans of the Google logos: les Google Doodles (is the official collection of all thematic logos :P )