A reader of our eXtreme Programming book asked us a guide to move from 0% TDD programming to 100% (or almost) TDD programming. But, there’s no manual that will really teach TDD, because it’s a practice. We could use a metaphor to explain it, TDD is like swimming, an activity that we practice.
Yes, TDD can be very hard at first time. Like swimming, you might not have enough breathing discipline, getting tired faster and giving it up. And after say “I didn’t like swimming, swimming is not for me”.
As a swimmer needs to jump in the water, a programmer needs to start with a failing test, write code until the test works, and refactor. And repeat these steps a lot of times. It’s a cycle, it’s a mantra:
After a lot of TDD cycles, you will be understanding how to practice TDD. So, please, jump in the water and enjoy TDD.
Refatoração: uma mudança feita na estrutura interna do software para deixá-lo mais fácil de entender e barato de modificar, sem mudar seu comportamento observável. Martin Fowler.
Além de refatorar código, pode-se também refatorar banco de dados. Hoje na Quarta do Conhecimento da PROCERGS o Fabrízio Mello palestrou sobre bad smells em databases, mostrando os diversos maus cheiros em banco de dados. Segue a apresentação: