Upload
toni-esteves
View
112
Download
1
Embed Size (px)
Citation preview
TDDA influência do Test-Driven Design no projeto de classes e no design em sistemas orientados a objetos
Big Design UpfrontWaterfall
Grupo de Pessoas
Grupo de Pessoas
Dis
cu
tam
H
ipó
tese
s
Dis
cu
tam
H
ipó
tese
s
Design!!!
Grupo de Pessoas
“Não existem requisitos de software, mas sim hipóteses.”
Agile Triangle
AgileResponder rapidamente ao negócio
En
tre
ga
su
ste
ntá
ve
l
Last Responsible Moment
Tempo
Contexto
Quando voceSupostamenteDeveria tomarUma decisão
Quanto maisVocê aguardar
Melhor a decisão
Last Responsible Moment
Equilíbrio
EquilíbrioLean Gerar valor
Engenharia de Software Ágil
Waterfall BDUF Agile
Go HorseProcess
Espectro do Design
“ Vamos deixar desse jeito que funciona, depois refatoramos e a estrutura e os patterns emergirão.”
Go Horse Proces
Dívida Técnica
- Eder Ignatowicz
Software
Apodrece
…- Eder Ignatowicz
“ Se você desenvolve iterativamente e não aplica práticas de engenharia ágil sua base de código morrerá em 2 ou 3 anos...
Não se preocupar com o design em um processo iterativo torna o projeto insustentável”
James Shore
Tempo
Cust
o d
e M
ud
ança
Desi
gn p
ronto
Manute
nçã
o
Muro
da Im
poss
ibili
dade d
e M
anute
nçã
o
Waterfall BUFD Agile
Go HorseProcess
Espectro do Design
EvolutionaryDesign
Evolutionary Design
Evolutionary DesignR
efa
cto
rin
g
Continuous Integration
Testing
Software Testing
Software Testing
Refactoring
Decrease ErrorsLow Coupling
Cohesiveness
Knowledge of bussiness
Trust code
TDD!!! <3
If you can’t write a test for what you are about to code, then you shouldn't even be thinking about coding- Chaplin 2001
A GOOD TEST, IS A FAIL TEST !!!
MicroTesting
Cenário
Ação
Validar
+
+
Teste
Teste
Código
JUnit
Red bar
Talk is cheap! Shut up and show me the
code !
Meu Deus, que coisa mais chata e ainda dá mais trabalho. Pra quê eu vou criar uma nova classe com métodos, se eu poderia fazer um método único main, com todos os possíveis erros e ver no console o resultado com System.out.println!?”..
“
O Que Testar ?
I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don't typically make a kind of mistake (like setting the wrong variables in a constructor), I don't test for it. I do tend to make sense of test errors, so I'm extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong.
Your micro tests TALKS !
Design bad smellson unit tests….
Você quer testar um método
privado.
Talvez sua classe tenha muitas
responsabilidades
Uma mudança no código quebraMuitos testes.
Violação do Open/Close
Principle
Instanciar uma classe
20 vezes
Alto Acoplamento
Testar é complicado por
causa do framework X
Baixa separação da Lógica quanto
ao Dominio
Você quer utilizar um framework de
Mock
Lei de Deméter
Difícil mockar uma classe.
Fraca Abstração
Dificil chamar um método ou
instancia uma classe.
Muitas responsabilidades
Muitos Assets
Violação do Single Responsibility
Principle
Code == Design
Domain DrivenDesign
Refactoring is not the same activity as redesign, where the programmers take a conscious decision to change a large-scale structure. That said,having taken a redesign decision, a team can use a refactoring techniques to get to new design incrementally and safely. ”
“
- Growing Object Oriented Software Guided By Tests
Things like TDD and Continuous Integration have fundamentally changed the safety in development.
”“
- Joshua Kerievsky
Como prat icar Design evolut ivo ?
Como cr iar s istemas res i tentes a mudanças
Como cr iar s istemas capazes de acomodar
constantes e cont inuas mudanças?
Como prover crec imento sustentável ?
Equilíbrio
Refa
ctori
ng Gerar valor
Testing/CI
+
Cultura de Aprendizado Colaborativo
Supere seus limites
Conviva com os melhores
Apêndices
http://crowdtest.me/10-falhas-software-marcaram-historia/
http://agilealliance.org
http://agilemanifesto.org
http://infoq.com
Lei de Deméter
SOLID Design Principles
Referências
http://www.agiledata.org/essays/tdd.html
http://blog.thiagobelem.net/aprendendo-tdd-ou-
desenvolvimento-orientado-a-testes/
http://www.slideshare.net/denisnferrari/tdd-completo
http://www.infoq.com/br/presentations/design-software-morreu
http://www.infoq.com/br/articles/relacao-tdd-qualidade
http://www.infoq.com/br/articles/levison-TDD-adoption-strategy
http://www.infoq.com/br/news/2010/08/por-onde-comecar-
meus-testes
toni_esteves
Software Craftsman;
Web Developer TRE-AL;
Graduando Sistemas de Informação;
I am a…