Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tdd workshop - Prime Factors Kata

Tdd workshop - Prime Factors Kata

c#, kata, primefactorskata, tdd, visualstudio, TeamSystem

Avatar for Luca Bonini

Luca Bonini

June 22, 2018
Tweet

More Decks by Luca Bonini

Other Decks in Technology

Transcript

  1. 3

  2. 4 The Three Laws of TDD 1. You are not

    allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
  3. Scomposizione in fattori primi La scomposizione in fattori primi (chiamata

    anche fattorizzazione) consiste nell'ottenere una serie di numeri che moltiplicati diano il numero originale, e che siano tutti numeri primi. Un numero è detto primo se è divisibile solo per se stesso e per 1. 6
  4. Esempio Come sappiamo un NUMERO si dice COMPOSTO quando ha

    qualche altro divisore oltre all'UNITA' e a SE STESSO. Sappiamo anche che i NUMERI PARI sono senz'altro dei NUMERI COMPOSTI, mentre i numeri dispari possono essere sia composti che primi. Scegliamo, quindi, un numero pari, ad esempio 30. Esso è senz'altro un numero composto e ammette, come divisore, il 2. Dividiamo allora per 2 e avremo: 30 : 2 = 15. Di conseguenza possiamo scrivere: 15 x 2 = 30. Anche 15 è un numero composto. Esso ha come più piccolo divisore il numero 3. Quindi possiamo scrivere: 15 : 3 = 5. E di conseguenza possiamo dire che: 3 x 5 = 15. Quindi attraverso una serie di sostituzioni possiamo dire che: 30 = 2 x 15 = 2 x 3 x 5. Ricapitolando: 30 = 2 x 3 x 5. Come possiamo notare abbiamo scritto il numero 30 come il prodotto di più numeri e questi numeri (2, 3, 5) sono tutti NUMERI PRIMI. Questa operazione prende il nome di SCOMPOSIZIONE di un NUMERO in FATTORI PRIMI. 7
  5. 9 ▪ ({}–>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. The Trasformations
  6. 10 Riferimenti The Three Laws of TDD http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd Scomposizione di

    un numero in FATTORI PRIMI http://www.lezionidimatematica.net/Numeri%20primi/lezioni/nupri_lezione_03.htm The Transformation Priority Premise https://8thlight.com/blog/uncle-bob/2013/05/27/TheTransformationPriorityPremise.html Robert C. Martin - Advanced TDD: The Transformation Priority Premise [VIDEO] https://vimeo.com/97516288 The Prime Factors Kata http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata