¡Por fin compila! No obstante, ¿otro programador sería capaz de entender tu código sin susurrar un solo WTF?
¿Es lo suficientemente claro como para que otro compañero no necesite días para entender lo que hace tu sistema?
7. ESCRIBIENDO CÓDIGO PARA HUMANOS
¿POR QUÉ ESCRIBIMOS “MAL” CÓDIGO?
▸ Rapidez
▸ Falta de motivación/experiencia
▸ Posponerlo para algún refactor
8. ESCRIBIENDO CÓDIGO PARA HUMANOS
CLEAN CODE
▸ Robert C. Martin [2008]
▸ “Even bad code can
function. But if code isn’t
clean, it can bring a
development organization
to its knees
9. “INDEED, THE RATIO OF TIME SPENT READING VERSUS WRITING IS
WELL OVER 10 TO 1. WE ARE CONSTANTLY READING OLD CODE AS
PART OF THE EFFORT TO WRITE NEW CODE. ...[THEREFORE,]
MAKING IT EASY TO READ MAKES IT EASIER TO WRITE.”
Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship
CLEAN CODE
24. CLEAN CODE
GESTIÓN DE ERRORES
▸ Evitar el uso de códigos de error
▸ Usar excepciones
▸ Cada vez que se devuelve Null muere un gatito
▸ … y cuando se pasa Null como parámetro también
41. SOLID
OPEN CLOSED PRINCIPLE (OCP)
“Software entities (classes, modules, functions,
etc.) should be open for extension, but closed for
modification”
45. SOLID
LISKOV SUBSTITUTION PRINCIPLE (LSP)
“Objects in a program should be replaceable with
instances of their subtypes without altering the
correctness of that program.”
55. SOLID
DEPENDENCY INVERSION PRINCIPLE (DIP)
“High-level modules should not depend on low-level
modules. Both should depend on abstractions.”
“Abstractions should not depend on details. Details
should depend on abstractions”
60. SOLID
CUIDADO CON LA SOBRE-INGENIERÍA
INTENTA SER PRAGMÁTICO
APLICA EL SENTIDO COMÚN
61.
62. ESCRIBIENDO CÓDIGO PARA HUMANOS
REFERENCIAS
▸ SOLID: The Definitive Guide - Arthur Antunes
▸ Clean Code - Robert C. Martin
▸ Principios de DOO - Robert C. Martin
▸ https://android.jlelse.eu/solid-principles-the-definitive-guide-75e30a284dea#.oofluhq1k
▸ http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
▸ https://www.amazon.es/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882