SlideShare uma empresa Scribd logo
1 de 11
Commentaires,
je t’aime…
un peu,
beaucoup,
à la folie,
pas du tout
Pas du tout
r = n / 2;
while ( abs( r - (n/r) ) > t ) {
r = 0.5 * ( r + (n/r) );
}
System.out.println( "r = " + r );
A la folie !
'*************************************************
' Name: CopyString
'
' Purpose: This routine copies a string from the source
' string (source) to the target string (target).
'
' Algorithm: It gets the length of "source" and then copies each
' character, one at a time, into "target". It uses
' the loop index as an array index into both "source"
' and "target" and increments the loop/array index
' after each character is copied.
'
' Inputs: input The string to be copied
'
' Outputs: output The string to receive the copy of "input"
'
' Interface Assumptions: None
'
' Modification History: None
'
' Author: Dwight K. Coder
' Date Created: 10/1/04
' Phone: (555) 222-2255
' SSN: 111-22-3333
' Eye Color: Green
' Maiden Name: None
' Blood Type: AB-
' Mother's Maiden Name: None
' Favorite Car: Pontiac Aztek
' Personalized License Plate: "Tek-ie"
'*************************************************
Ce genre de commentaires
// Declare category id for products
const int prodCategoryId = 1024;
// Create an iterator over products
vector<Product>::iterator iter = products_.begin();
// Iterate through all products
for ( ; iter != products_.end(); ++iter )
{
// Assign categody id to each product
iter->AssignCategoryId( prodCategoryId );
} // end for
Cela me fait penser à :
// Increase i by one
i++;
Le « Pourquoi »,
et non le « Comment »
// Assign categody id to each product
const int prodCategoryId = 1024;
vector<Product>::iterator iter = products_.begin();
for ( ; iter != products_.end(); ++iter )
{
iter->AssignCategoryId( prodCategoryId );
}
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
Je nommerais correctement mes variables
const int bookCategoryId = 1024;
void assignCategoryToEachProducts(int categoryId, vector<Product> products)
{
vector<Product>::iterator productsIterator = products.begin();
for ( ; productsIterator != products.end(); ++productsIterator )
{
productsIterator->AssignCategoryId( categoryId );
}
}
 Voyez un commentaire comme un aveu de faiblesse
 Codez toujours en pensant que celui qui maintiendra votre code est
un psychopathe qui connait votre adresse
Martin Golding
Imperative
vs
Declarative
var numbers = [1,2,3,4,5]
var doubled = []
for(var i = 0; i < numbers.length; i++) {
var newNumber = numbers[i] * 2
doubled.push(newNumber)
}
console.log(doubled) //=> [2,4,6,8,10]
var numbers = [1,2,3,4,5]
var doubled = numbers.map(function(n) {
return n * 2
})
console.log(doubled) //=> [2,4,6,8,10]
var dogsWithOwners = []
var dog, owner
for(var di=0; di < dogs.length; di++) {
dog = dogs[di]
for(var oi=0; oi < owners.length; oi++) {
owner = owners[oi]
if (owner && dog.owner_id == owner.id) {
dogsWithOwners.push({
dog: dog,
owner: owner
})
}
}}
}
SELECT * from dogs
INNER JOIN owners
WHERE dogs.owner_id = owners.id
var data = [{x: 5, y: 10}, {x: 20, y: 5}]
var circles = svg.selectAll('circle')
.data(data)
circles.enter().append('circle')
.attr('cx', function(d) { return d.x })
.attr('cy', function(d) { return d.y })
.attr('r', 0)
.transition().duration(500)
.attr('r', 5)
D3.js
Merci
 Source :
 http://latentflip.com/imperative-vs-declarative/
 http://www.infoq.com/news/2010/03/To-Comment-or-Not-to-Comment
 http://blog.codinghorror.com/coding-without-comments/

Mais conteúdo relacionado

Mais procurados

Introduction à JavaScript
Introduction à JavaScriptIntroduction à JavaScript
Introduction à JavaScriptMicrosoft
 
Javascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryJavascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryneuros
 
Javascript #4.2 : fonctions for pgm
Javascript #4.2 : fonctions for pgmJavascript #4.2 : fonctions for pgm
Javascript #4.2 : fonctions for pgmJean Michel
 
Javascript #2 : valeurs, types & opérateurs
Javascript #2 : valeurs, types & opérateursJavascript #2 : valeurs, types & opérateurs
Javascript #2 : valeurs, types & opérateursJean Michel
 
Pourquoi Ruby et Ruby On Rais sont geniaux ?
Pourquoi Ruby et Ruby On Rais sont geniaux ?Pourquoi Ruby et Ruby On Rais sont geniaux ?
Pourquoi Ruby et Ruby On Rais sont geniaux ?Maxime Menant
 
CocoaHeads Rennes #1 : Grand Central Dispatch
CocoaHeads Rennes #1 : Grand Central DispatchCocoaHeads Rennes #1 : Grand Central Dispatch
CocoaHeads Rennes #1 : Grand Central DispatchCocoaHeadsRNS
 
Présentation de ECMAScript 6
Présentation de ECMAScript 6Présentation de ECMAScript 6
Présentation de ECMAScript 6Julien CROUZET
 
PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles Jean Michel
 
PHP & MYSQL #5 : fonctions
PHP & MYSQL #5 :  fonctionsPHP & MYSQL #5 :  fonctions
PHP & MYSQL #5 : fonctionsJean Michel
 
Notions de base de JavaScript
Notions de base de JavaScriptNotions de base de JavaScript
Notions de base de JavaScriptKristen Le Liboux
 

Mais procurados (16)

Python avancé : Qualité de code et convention de codage
Python avancé : Qualité de code et convention de codagePython avancé : Qualité de code et convention de codage
Python avancé : Qualité de code et convention de codage
 
Php1
Php1Php1
Php1
 
Formation python
Formation pythonFormation python
Formation python
 
Introduction à JavaScript
Introduction à JavaScriptIntroduction à JavaScript
Introduction à JavaScript
 
Johnny-Five : Robotique et IoT en JavaScript
Johnny-Five : Robotique et IoT en JavaScriptJohnny-Five : Robotique et IoT en JavaScript
Johnny-Five : Robotique et IoT en JavaScript
 
Javascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryJavascript ne se limite pas à jquery
Javascript ne se limite pas à jquery
 
PHP &amp; MySQL
PHP &amp; MySQLPHP &amp; MySQL
PHP &amp; MySQL
 
Cours java script
Cours java scriptCours java script
Cours java script
 
Javascript #4.2 : fonctions for pgm
Javascript #4.2 : fonctions for pgmJavascript #4.2 : fonctions for pgm
Javascript #4.2 : fonctions for pgm
 
Javascript #2 : valeurs, types & opérateurs
Javascript #2 : valeurs, types & opérateursJavascript #2 : valeurs, types & opérateurs
Javascript #2 : valeurs, types & opérateurs
 
Pourquoi Ruby et Ruby On Rais sont geniaux ?
Pourquoi Ruby et Ruby On Rais sont geniaux ?Pourquoi Ruby et Ruby On Rais sont geniaux ?
Pourquoi Ruby et Ruby On Rais sont geniaux ?
 
CocoaHeads Rennes #1 : Grand Central Dispatch
CocoaHeads Rennes #1 : Grand Central DispatchCocoaHeads Rennes #1 : Grand Central Dispatch
CocoaHeads Rennes #1 : Grand Central Dispatch
 
Présentation de ECMAScript 6
Présentation de ECMAScript 6Présentation de ECMAScript 6
Présentation de ECMAScript 6
 
PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles
 
PHP & MYSQL #5 : fonctions
PHP & MYSQL #5 :  fonctionsPHP & MYSQL #5 :  fonctions
PHP & MYSQL #5 : fonctions
 
Notions de base de JavaScript
Notions de base de JavaScriptNotions de base de JavaScript
Notions de base de JavaScript
 

Destaque

Compo nova tec libramont 2014 fr
Compo nova tec libramont 2014 frCompo nova tec libramont 2014 fr
Compo nova tec libramont 2014 frBelfertil Mobile
 
Le maître de l'olympe
Le maître de l'olympeLe maître de l'olympe
Le maître de l'olympeAlagar05
 
Travailler ensemble autour du PLU intercommunal : les préalables à la démarche
Travailler ensemble autour du PLU intercommunal : les préalables à la démarcheTravailler ensemble autour du PLU intercommunal : les préalables à la démarche
Travailler ensemble autour du PLU intercommunal : les préalables à la démarcheCAUE85
 
La discrimin ai etion kit de sensibilisation des jeunes
La discrimin ai etion kit de sensibilisation des jeunesLa discrimin ai etion kit de sensibilisation des jeunes
La discrimin ai etion kit de sensibilisation des jeunesLesZegaux
 
Programa de Buenas Practicas de Fabricación
Programa de Buenas Practicas de FabricaciónPrograma de Buenas Practicas de Fabricación
Programa de Buenas Practicas de FabricaciónConectaDEL
 
Presentación de avances ConectaDEL 2012
Presentación de avances ConectaDEL 2012Presentación de avances ConectaDEL 2012
Presentación de avances ConectaDEL 2012ConectaDEL
 
Una conferencia sobre La Grieta
Una conferencia sobre La GrietaUna conferencia sobre La Grieta
Una conferencia sobre La GrietaJorge Sardi
 
Avis Kustom Store Motorcycles Kit Air Ride
Avis Kustom Store Motorcycles Kit Air RideAvis Kustom Store Motorcycles Kit Air Ride
Avis Kustom Store Motorcycles Kit Air RideKustom Store Motorcycles
 
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...ConectaDEL
 
Facebook, un incontournable pour la diffusion!
Facebook, un incontournable pour la diffusion!Facebook, un incontournable pour la diffusion!
Facebook, un incontournable pour la diffusion!Mylène Bélanger
 
Organizacion escolar
Organizacion escolarOrganizacion escolar
Organizacion escolarultrapegaso
 

Destaque (20)

Monument mémoire
Monument mémoireMonument mémoire
Monument mémoire
 
ART SKA
ART SKAART SKA
ART SKA
 
Compo nova tec libramont 2014 fr
Compo nova tec libramont 2014 frCompo nova tec libramont 2014 fr
Compo nova tec libramont 2014 fr
 
Mes amis
Mes amisMes amis
Mes amis
 
Le maître de l'olympe
Le maître de l'olympeLe maître de l'olympe
Le maître de l'olympe
 
Mouse
MouseMouse
Mouse
 
Travailler ensemble autour du PLU intercommunal : les préalables à la démarche
Travailler ensemble autour du PLU intercommunal : les préalables à la démarcheTravailler ensemble autour du PLU intercommunal : les préalables à la démarche
Travailler ensemble autour du PLU intercommunal : les préalables à la démarche
 
La discrimin ai etion kit de sensibilisation des jeunes
La discrimin ai etion kit de sensibilisation des jeunesLa discrimin ai etion kit de sensibilisation des jeunes
La discrimin ai etion kit de sensibilisation des jeunes
 
Programa de Buenas Practicas de Fabricación
Programa de Buenas Practicas de FabricaciónPrograma de Buenas Practicas de Fabricación
Programa de Buenas Practicas de Fabricación
 
6th me question papers dec 2013
6th me question papers dec 20136th me question papers dec 2013
6th me question papers dec 2013
 
Presentación de avances ConectaDEL 2012
Presentación de avances ConectaDEL 2012Presentación de avances ConectaDEL 2012
Presentación de avances ConectaDEL 2012
 
APPROACHES OF LAND USE AND MANAGEMENT FOR CLIMATE RESILIENCE
APPROACHES OF LAND USE  AND MANAGEMENT FOR CLIMATE RESILIENCEAPPROACHES OF LAND USE  AND MANAGEMENT FOR CLIMATE RESILIENCE
APPROACHES OF LAND USE AND MANAGEMENT FOR CLIMATE RESILIENCE
 
Una conferencia sobre La Grieta
Una conferencia sobre La GrietaUna conferencia sobre La Grieta
Una conferencia sobre La Grieta
 
Le futur
Le futurLe futur
Le futur
 
Capital Payment
Capital PaymentCapital Payment
Capital Payment
 
Avis Kustom Store Motorcycles Kit Air Ride
Avis Kustom Store Motorcycles Kit Air RideAvis Kustom Store Motorcycles Kit Air Ride
Avis Kustom Store Motorcycles Kit Air Ride
 
Londres
LondresLondres
Londres
 
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...
Guía Metodológica de Desarrollo Económico Territorial. Parte 1: Proposiciones...
 
Facebook, un incontournable pour la diffusion!
Facebook, un incontournable pour la diffusion!Facebook, un incontournable pour la diffusion!
Facebook, un incontournable pour la diffusion!
 
Organizacion escolar
Organizacion escolarOrganizacion escolar
Organizacion escolar
 

Semelhante a HumanTalk - Commentaires, je t'aime un peu, beaucoup, à la folie, pas du tout

Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Guillaume Laforge
 
Tableau objetjava
Tableau objetjavaTableau objetjava
Tableau objetjavaMoez Moezm
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la viecluelessjoe
 
Eléments du langage Java.pdf
Eléments du langage  Java.pdfEléments du langage  Java.pdf
Eléments du langage Java.pdfAabidiHafid
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introductionneuros
 
Rendez votre code Python plus beau !
Rendez votre code Python plus beau !Rendez votre code Python plus beau !
Rendez votre code Python plus beau !Ronan Amicel
 
C++ Metaprogramming : multidimensional typelist
C++ Metaprogramming : multidimensional typelistC++ Metaprogramming : multidimensional typelist
C++ Metaprogramming : multidimensional typelistVincent Agnus
 
Android Optimisations Greendroid
Android Optimisations GreendroidAndroid Optimisations Greendroid
Android Optimisations GreendroidGDG Nantes
 
Javascript : que fait ce code?
Javascript : que fait ce code?Javascript : que fait ce code?
Javascript : que fait ce code?Ruau Mickael
 
Intégration web MMI
Intégration web MMIIntégration web MMI
Intégration web MMIPierre VERT
 
Programmation orientée objet : Object, classe et encapsulation
Programmation orientée objet : Object, classe et encapsulationProgrammation orientée objet : Object, classe et encapsulation
Programmation orientée objet : Object, classe et encapsulationECAM Brussels Engineering School
 
initiation au javascript
initiation au javascriptinitiation au javascript
initiation au javascriptAbdoulaye Dieng
 

Semelhante a HumanTalk - Commentaires, je t'aime un peu, beaucoup, à la folie, pas du tout (20)

Les bases du javascript
Les bases du javascriptLes bases du javascript
Les bases du javascript
 
Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013
 
Tableau objetjava
Tableau objetjavaTableau objetjava
Tableau objetjava
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la vie
 
Cours php
Cours phpCours php
Cours php
 
Eléments du langage Java.pdf
Eléments du langage  Java.pdfEléments du langage  Java.pdf
Eléments du langage Java.pdf
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introduction
 
La première partie de la présentation PHP
La première partie de la présentation PHPLa première partie de la présentation PHP
La première partie de la présentation PHP
 
Cours tp2
Cours tp2Cours tp2
Cours tp2
 
Rendez votre code Python plus beau !
Rendez votre code Python plus beau !Rendez votre code Python plus beau !
Rendez votre code Python plus beau !
 
Audits php
Audits phpAudits php
Audits php
 
XebiConFr 15 - Swift dans la vraie vie
XebiConFr 15 - Swift dans la vraie vieXebiConFr 15 - Swift dans la vraie vie
XebiConFr 15 - Swift dans la vraie vie
 
C++ Metaprogramming : multidimensional typelist
C++ Metaprogramming : multidimensional typelistC++ Metaprogramming : multidimensional typelist
C++ Metaprogramming : multidimensional typelist
 
Android Optimisations Greendroid
Android Optimisations GreendroidAndroid Optimisations Greendroid
Android Optimisations Greendroid
 
Javascript : que fait ce code?
Javascript : que fait ce code?Javascript : que fait ce code?
Javascript : que fait ce code?
 
Php4 Mysql
Php4 MysqlPhp4 Mysql
Php4 Mysql
 
Intégration web MMI
Intégration web MMIIntégration web MMI
Intégration web MMI
 
Programmation orientée objet : Object, classe et encapsulation
Programmation orientée objet : Object, classe et encapsulationProgrammation orientée objet : Object, classe et encapsulation
Programmation orientée objet : Object, classe et encapsulation
 
initiation au javascript
initiation au javascriptinitiation au javascript
initiation au javascript
 
C++ 11/14
C++ 11/14C++ 11/14
C++ 11/14
 

Mais de florentpellet

Split my monolith - Devoxx
Split my monolith - DevoxxSplit my monolith - Devoxx
Split my monolith - Devoxxflorentpellet
 
Comment faire un mur végétal chez soi ?
Comment faire un mur végétal chez soi ?Comment faire un mur végétal chez soi ?
Comment faire un mur végétal chez soi ?florentpellet
 
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?florentpellet
 
TDD outside in - Coding Dojo Lyon
TDD outside in - Coding Dojo LyonTDD outside in - Coding Dojo Lyon
TDD outside in - Coding Dojo Lyonflorentpellet
 
Global Day of Coderetreat - Lyon 2015
Global Day of Coderetreat - Lyon 2015Global Day of Coderetreat - Lyon 2015
Global Day of Coderetreat - Lyon 2015florentpellet
 
CARA Coding Dojo - Outils de tests
CARA Coding Dojo - Outils de testsCARA Coding Dojo - Outils de tests
CARA Coding Dojo - Outils de testsflorentpellet
 
CARA Coding dojo - Golden Master
CARA Coding dojo - Golden MasterCARA Coding dojo - Golden Master
CARA Coding dojo - Golden Masterflorentpellet
 
CARA Coding Dojo - SOLID
CARA Coding Dojo - SOLIDCARA Coding Dojo - SOLID
CARA Coding Dojo - SOLIDflorentpellet
 
CARA Coding Dojo TDD Palindrome (décembre 2014)
CARA Coding Dojo TDD Palindrome (décembre 2014)CARA Coding Dojo TDD Palindrome (décembre 2014)
CARA Coding Dojo TDD Palindrome (décembre 2014)florentpellet
 
GWAB Lyon - Legacy code atelier
GWAB Lyon - Legacy code atelierGWAB Lyon - Legacy code atelier
GWAB Lyon - Legacy code atelierflorentpellet
 
Single Page Application: Enrichissez l'expérience utilisateur
Single Page Application: Enrichissez l'expérience utilisateurSingle Page Application: Enrichissez l'expérience utilisateur
Single Page Application: Enrichissez l'expérience utilisateurflorentpellet
 

Mais de florentpellet (15)

Split my monolith - Devoxx
Split my monolith - DevoxxSplit my monolith - Devoxx
Split my monolith - Devoxx
 
Comment faire un mur végétal chez soi ?
Comment faire un mur végétal chez soi ?Comment faire un mur végétal chez soi ?
Comment faire un mur végétal chez soi ?
 
Lyon Tech Hub
Lyon Tech HubLyon Tech Hub
Lyon Tech Hub
 
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?
CARA - Software Craftsmanship : le chaînon manquant de l’agilité ?
 
TDD outside in - Coding Dojo Lyon
TDD outside in - Coding Dojo LyonTDD outside in - Coding Dojo Lyon
TDD outside in - Coding Dojo Lyon
 
Global Day of Coderetreat - Lyon 2015
Global Day of Coderetreat - Lyon 2015Global Day of Coderetreat - Lyon 2015
Global Day of Coderetreat - Lyon 2015
 
201506 mug intro
201506 mug intro201506 mug intro
201506 mug intro
 
Event storming
Event stormingEvent storming
Event storming
 
CARA Coding Dojo - Outils de tests
CARA Coding Dojo - Outils de testsCARA Coding Dojo - Outils de tests
CARA Coding Dojo - Outils de tests
 
CARA Coding dojo - Golden Master
CARA Coding dojo - Golden MasterCARA Coding dojo - Golden Master
CARA Coding dojo - Golden Master
 
CARA Coding Dojo - SOLID
CARA Coding Dojo - SOLIDCARA Coding Dojo - SOLID
CARA Coding Dojo - SOLID
 
CARA Coding Dojo TDD Palindrome (décembre 2014)
CARA Coding Dojo TDD Palindrome (décembre 2014)CARA Coding Dojo TDD Palindrome (décembre 2014)
CARA Coding Dojo TDD Palindrome (décembre 2014)
 
GWAB Lyon - Legacy code atelier
GWAB Lyon - Legacy code atelierGWAB Lyon - Legacy code atelier
GWAB Lyon - Legacy code atelier
 
Crafting workshop
Crafting workshopCrafting workshop
Crafting workshop
 
Single Page Application: Enrichissez l'expérience utilisateur
Single Page Application: Enrichissez l'expérience utilisateurSingle Page Application: Enrichissez l'expérience utilisateur
Single Page Application: Enrichissez l'expérience utilisateur
 

HumanTalk - Commentaires, je t'aime un peu, beaucoup, à la folie, pas du tout

  • 2. Pas du tout r = n / 2; while ( abs( r - (n/r) ) > t ) { r = 0.5 * ( r + (n/r) ); } System.out.println( "r = " + r );
  • 3. A la folie ! '************************************************* ' Name: CopyString ' ' Purpose: This routine copies a string from the source ' string (source) to the target string (target). ' ' Algorithm: It gets the length of "source" and then copies each ' character, one at a time, into "target". It uses ' the loop index as an array index into both "source" ' and "target" and increments the loop/array index ' after each character is copied. ' ' Inputs: input The string to be copied ' ' Outputs: output The string to receive the copy of "input" ' ' Interface Assumptions: None ' ' Modification History: None ' ' Author: Dwight K. Coder ' Date Created: 10/1/04 ' Phone: (555) 222-2255 ' SSN: 111-22-3333 ' Eye Color: Green ' Maiden Name: None ' Blood Type: AB- ' Mother's Maiden Name: None ' Favorite Car: Pontiac Aztek ' Personalized License Plate: "Tek-ie" '*************************************************
  • 4. Ce genre de commentaires // Declare category id for products const int prodCategoryId = 1024; // Create an iterator over products vector<Product>::iterator iter = products_.begin(); // Iterate through all products for ( ; iter != products_.end(); ++iter ) { // Assign categody id to each product iter->AssignCategoryId( prodCategoryId ); } // end for Cela me fait penser à : // Increase i by one i++;
  • 5. Le « Pourquoi », et non le « Comment » // Assign categody id to each product const int prodCategoryId = 1024; vector<Product>::iterator iter = products_.begin(); for ( ; iter != products_.end(); ++iter ) { iter->AssignCategoryId( prodCategoryId ); }
  • 6. Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables Je nommerais correctement mes variables const int bookCategoryId = 1024; void assignCategoryToEachProducts(int categoryId, vector<Product> products) { vector<Product>::iterator productsIterator = products.begin(); for ( ; productsIterator != products.end(); ++productsIterator ) { productsIterator->AssignCategoryId( categoryId ); } }
  • 7.  Voyez un commentaire comme un aveu de faiblesse  Codez toujours en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse Martin Golding
  • 8. Imperative vs Declarative var numbers = [1,2,3,4,5] var doubled = [] for(var i = 0; i < numbers.length; i++) { var newNumber = numbers[i] * 2 doubled.push(newNumber) } console.log(doubled) //=> [2,4,6,8,10] var numbers = [1,2,3,4,5] var doubled = numbers.map(function(n) { return n * 2 }) console.log(doubled) //=> [2,4,6,8,10]
  • 9. var dogsWithOwners = [] var dog, owner for(var di=0; di < dogs.length; di++) { dog = dogs[di] for(var oi=0; oi < owners.length; oi++) { owner = owners[oi] if (owner && dog.owner_id == owner.id) { dogsWithOwners.push({ dog: dog, owner: owner }) } }} } SELECT * from dogs INNER JOIN owners WHERE dogs.owner_id = owners.id
  • 10. var data = [{x: 5, y: 10}, {x: 20, y: 5}] var circles = svg.selectAll('circle') .data(data) circles.enter().append('circle') .attr('cx', function(d) { return d.x }) .attr('cy', function(d) { return d.y }) .attr('r', 0) .transition().duration(500) .attr('r', 5) D3.js
  • 11. Merci  Source :  http://latentflip.com/imperative-vs-declarative/  http://www.infoq.com/news/2010/03/To-Comment-or-Not-to-Comment  http://blog.codinghorror.com/coding-without-comments/