More Related Content Similar to Porqué Cervantes programaba mejor que tú Similar to Porqué Cervantes programaba mejor que tú (20) More from Agile Spain (20) Porqué Cervantes programaba mejor que tú1. Por qué Cervantes
programaba mejor que tú
Javier Acero
@jacegu
http://javieracero.com
7. Code Business
Quality!! Value!!
25. 011000100110010101110011
011000010010000001101101
011010010010000001100010
011100100110100101101100
011011000110000101101110
011101000110010100100000
011000110111010101101100
011011110010000001101101
011001010111010011000011
101000010110110001101001
0110001101101111
besa mi brillante culo metálico
30. segment .text
global two_complement
two_complement:
enter 0,0
pusha
mov eax, [ebp+12]
neg eax
mov [ebp+8], eax
popa
leave
ret
31. private void updateComputer(Node n,
Map<String,Computer> byNameMap,
Set<Computer> used) {
Computer c;
c = byNameMap.get(n.getNodeName());
if (c!=null) {
c.setNode(n);
} else {
if(n.getNumExecutors()>0) {
computers.put(n,c=n.createComputer());
if (!n.holdOffLaunchUntilSave && AUTOMATIC_SLAVE_LAUNCH) {
RetentionStrategy retentionStrategy =
c.getRetentionStrategy();
if (retentionStrategy != null) {
retentionStrategy.start(c);
} else {
c.connect(true);
}
}
}
}
used.add(c);
}
44. Information hiding Open Closed Principle
Uniform Access Duplication
KISS Single Responsibility Principle
Simple Design
GRASP Expresiveness
Law of Demeter Auto-documentation
Interface Segregation Principle Design Patterns
YAGNI Liskov Substitution Principle
Naming
Dependencies DRY Simmetry
Least Surprise
Dependency Inversion Principle Cohesion
49. private void updateComputer(Node n,
Map<String,Computer> byNameMap,
Set<Computer> used) {
Computer c;
c = byNameMap.get(n.getNodeName());
if (c!=null) {
c.setNode(n);
} else {
if(n.getNumExecutors()>0) {
computers.put(n,c=n.createComputer());
if (!n.holdOffLaunchUntilSave && AUTOMATIC_SLAVE_LAUNCH) {
RetentionStrategy retentionStrategy =
c.getRetentionStrategy();
if (retentionStrategy != null) {
retentionStrategy.start(c);
} else {
c.connect(true);
}
}
}
}
used.add(c);
}
51. You know you are working on good code when
each routine you read turns out to be pretty
much what you expected.
You can call it beautiful when the code also
makes it look like the language was made for
the problem.
52. Good code is simple and direct. Good code reads
like well-written prose.
Good code never obscures the designer’s intent
but rather is full of crisp abstractions and
straightforward lines of control.
54. la mejor forma de escribir
buen código es centrarse en la
legibilidad*
*creencia personal
61. for (final ConfiguracionCanal c : mensaje.
getSolicitud().
getServicio().
getConfiguracionesCanal()) {
if (mensaje.getCanal().equals(c.
getCanal())) {
configuracion = c;
}
}
66. las 4 cualidades del
diseño simple
1. Pasa todos los tests
2. Minimiza la duplicación
3. Maximiza la claridad
4. Tiene los mínimos elementos
70. def d(b)
eval"def #{b} end"
end
d 't(m,&a)puts"e[0;3#{a.call ?
"2":"1"}m#{m}e[0m"'
d 'a(e)e'
d 'ae(e,d)e==d'
d 'ai(e,a)a.include? e'
71. t '(red): testing that assert
equals fails' do
ae(1,2)
end
t '(green): testing that assert
equals works' do
ae(2,2)
end
75. las 4 cualidades del
diseño simple
1. Pasa todos los tests
2. Minimiza la duplicación
76. las 4 cualidades del
diseño simple
1. Pasa todos los tests
2. Minimiza la duplicación
3. Maximiza la claridad
77. las 4 cualidades del
diseño simple
1. Pasa todos los tests
2. Minimiza la duplicación
3. Maximiza la claridad
4. Tiene los mínimos elementos
79. def d(b)
eval"def #{b} end"
end
d 't(m,&a)puts"e[0;3#{a.call ?
"2":"1"}m#{m}e[0m"'
d 'a(e)e'
d 'ae(e,d)e==d'
d 'ai(e,a)a.include? e'
80. def d(b)
eval"def #{b} end"
end
d 't(m,&a)puts"e[0;3#{a.call ?
"2":"1"}m#{m}e[0m"'
d 'a(e)e'
d 'ae(e,d)e==d'
d 'ai(e,a)a.include? e'
81. def d(b)
eval"def #{b} end"
end
d 't(m,&a)puts"e[0;3#{a.call ?
"2":"1"}m#{m}e[0m"'
d 'a(e)e'
d 'ae(e,d)e==d'
d 'ai(e,a)a.include? e'
83. def assert(value)
return value == true
end
def assert_equal(value, expected)
return value == expected
end
def assert_includes(value, container)
return container.include? value
end
84. def d(b)
eval"def #{b} end"
end
d 't(m,&a)puts"e[0;3#{a.call ?
"2":"1"}m#{m}e[0m"'
d 'a(e)e'
d 'ae(e,d)e==d'
d 'ai(e,a)a.include? e'
91. si el test pasa
imprimir en verde el nombre del test
sino
imprimir en rojo el nombre del test
95. Good code always looks like it was written
by someone who cares.
Good code is code left by someone who
cares deeply about the craft.
97. credits
Kent Beck: http://www.flickr.com/photos/26420411@N02/3062930943/
Opposing Armies: http://www.flickr.com/photos/ahounslea/4873239128
Ward Cunningham: http://www.flickr.com/photos/joshb/2247556208/
Uncle Bob: http://www.flickr.com/photos/koss/3250213001/
Balance: http://www.flickr.com/photos/classblog/5136926303/
Futurama pictures and WTFs/minute draws were found on google
searches.
Hand drawings of Grady Booch, Ward Cunningham and Michael
Feathers were taken from the Clean Code ebook.