Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TDD a piccoli passi

793 views

Published on

Le slide della sessione che ho tenuto agli Italian Agile Days del 2016, Pavia, 18-19 Novembre

Published in: Software
  • Be the first to comment

TDD a piccoli passi

  1. 1. Ferdinando Santacroce @JesusWasRasta TDD a piccoli passi
  2. 2. All’inizio le mie applicazioni le testavo così...
  3. 3. Vediamo un po’ come funziona...
  4. 4. mmm, pensavo fosse meno complicato...
  5. 5. Ho capito, devo usare i mock!
  6. 6. Sì, ma che fatica!
  7. 7. Driven!!
  8. 8. Cos’è TDD? Scrivi dei test Scrivi codice fino a farli passare tutti Fai un po’ di pulizia
  9. 9. The Three Laws of TDD 1. “You aren’t allowed to write any production code until you have written a failing unit test”. 2. “You aren’t allowed to write more of a unit test than is sufficient to fail. And not compiling is failing.” 3. “You aren’t allowed to write more production code than is sufficient to pass the currently failing unit test.”
  10. 10. Ecco cos’è TDD! Write a single test that fails Write code to make the test pass Improve the code base
  11. 11. The Three Laws of TDD 1. “You aren’t allowed to write any production code until you have written a failing unit test”. 2.“You aren’t allowed to write more of a unit test than is sufficient to fail. And not compiling is failing.” 3. “You aren’t allowed to write more production code than is sufficient to pass the currently failing unit test.”
  12. 12. Proviamoci! See the code on Github: https://github.com/jesuswasrasta/SmallStepsTDD.git
  13. 13. • Nell’algoritmo non v’è espresso il concetto di numero primo • Brainlessness (2 -> n) • I cicli sono una generalizzazione delle if • Passo dei test nuovi senza modificare codice • Se immaginiamo i test come feature, che bello sarebbe aggiungere funzionalità al nostro software con questa facilità?! • Refactoring: rimuovere duplicazione, rimuovere codice Cosa si nota?
  14. 14. ({}–>nil) no code at all->code that employs nil (nil->constant) (constant->constant+) a simple constant to a more complex constant (constant->scalar) replacing a constant with a variable or an argument (statement->statements) adding more unconditional statements. (unconditional->if) splitting the execution path (scalar->array) (array->container) (statement->recursion) (if->while) (expression->function) replacing an expression with a function or algorithm (variable->assignment) replacing the value of a variable. Transformations
  15. 15. https://8thlight.com/blog/uncle- bob/2013/05/27/TheTransformationPriorityPremise.html https://en.wikipedia.org/wiki/Transformation_Priority_Premise https://www.youtube.com/watch?v=B93QezwTQpI https://vimeo.com/97516288 https://vimeo.com/60561303 Transformations Priority Premise Robert C. Martin (Uncle Bob)
  16. 16. @JesusWasRasta DOmande? @JesusWasRasta

×