23. January 2008 20:32Comentar, comentar, comentar

Seguro que más de una vez os habrá tocado leer código de otra persona. Problablemente esa persona ya no estuviera en la empresa y lo que es mejor, seguro que toda la documentación estaba en su cabeza. Todos hemos sufrido esa desgracia y hemos sentido la necesidad de aporrear el teclado al estilo niño loco alemán. ¿Pero hemos hecho algo para cambiar esto?¿Escribimos más líneas de comentarios que de código pensando en la persona que va a venir detrás de nosotros? Noooo, claro que no. El tiempo que pasamos comentando lo podemos pasar picando código que es para lo que nos pagan. Pero no os preocupéis, he encontrado la solución: Cenqua: The Commentator. Cenqua es un comentador automático de código altamente configurable:

int sum = 0;   
for (int i= 0; i < a.length; i++) {
sum += a[i];
}

Puede convertirse en:

 //okey dokey, lets sum the elements of a   
int sum = 0;
// the sum of all fears
for (int i= 0; i < a.length; i++) {
sum += a[i];
// all your a[i] are belong to us
}

O también en:

int sum = 0;   
//don''t even fucking *think* about asking
for (int i= 0; i < a.length; i++) {
sum += a[i];
}

O:

int sum = 0;   
//avoid using the reverse "i >= 0; i--" style loop here,
//it would obviously be more efficient, but blows up in gcc
//under linux and solaris
for (int i= 0; i < a.length; i++) {
//always use += where possible, its faster
sum += a[i];
}

 

/*******************************************************   
* okay, finally we are ready to take the important step of
* summing the integer elements of a. I''ve researched the
* most efficient algorithm and settled on this one,
* presented by Knuth. I don''t quite agree with his
* reasoning but the algorithm is sound (did I tell you
* about the cheque I got from Knuth? no? It was back
* in my uni days when I was writing my thesis (youngest
* ever accepted into the program) in TeX on the PDP-10.
* I just couldn''t get it to format my differential
* equations properly, and a quick look under the hood...
No lo dudes más, aumenta tu productividad con Cenqua: The Commentator.

Comments

Powered by BlogEngine.NET 1.4.5.0
Theme by molant