giovedì 14 gennaio 2010

CleanCode/2 - It is not enough for code to work

Chiedo scusa a quanti si risentirono pesantemente quel giorno quando dissi che il codice prodotto di corsa in un mese di overtime non fosse di qualità. Perchè di qualità si trattava, non del fatto che funzionasse o meno, non del fatto che il cliente ne fosse soddisfatto o meno. Non era mia intenzione sminuire il lavoro di nessuno.
Perdonatemi, ma...
It is not enough for code to work. Code that works is often badly broken. Programmers who satisfy themselves with merely working code are behaving unprofessionally. They may fear that they don't have time to improve the structure and design of their code, but I disagree. Nothing has a more profound and long-term degrading effect upon a development project than bad code.
Bad schedules can be redone, bad requirements can be redefined. Bad team dynamics can be repaired. But bad code rots and ferments, becoming an inexorable weight that drags the team down. tiem and time again I have seen teams grind to a crawl because, in their haste, they created a malignant morass of code that forever thereafter dominated their destiny.
Of course bad code can be cleaned up. But it's very expensive. As code rots, the moules insinuate themselves into each other, creating lots of hidden and tangled dependencies is a long and arduous task. If you made a mess in a module in the morning , it is easy to clean it up in the afternoon. Better yet, if you made a mess five minutes ago, it's very easy to clean it up rigt now.
So the solution is to continuously keep code as clean and simple as it can be. Never let the rot get started.
Chapter 14: Successive Refinement - Conclusion - pag. 250

Ricordate quando tante volte abbiamo ripensato al passato e ci siamo chiesti "Ma perchè abbiamo fallito?". Personalmente aggiungo questa qui: non sappiamo scrivere codice pulito.

1 commento:

  1. Never let the rot get started... Easier said than done :-(

    Io penso che a qualcuno (tristemente a volte capita anche a noi) non interessi neanche scrivere codice pulito, specialmente in contesti in cui la qualità del software non viene considerata come un elemento importante (avevo commentato qua in merito a uno studio sull'argomento). Da qua al non essere capaci è un attimo, perché se mancano l'attenzione alla qualità e la relativa cultura non può che mancare l'esperienza con le relative conseguenze.

    Sono un po' pessimista e mi domando in quanti effettivamente si chiedano "ma perché abbiamo fallito?", e temo che la maggior parte delle persone guardi all'esterno per cercare la risposta. Solitamente non trovandola, per tutti i motivi che hai scritto.

    E' vero che a volte quick and dirty va benissimo, ma non direi proprio che si possa applicare a progetti con un minimo di complessità (cioè praticamente tutti): cattiva qualità significa costi elevati. Molto elevati. Prima ce ne renderemo conto tutti meglio sarà.

    RispondiElimina