@theNeomatrix369 @pedromsantos
Refactoring
Developer
Habits
@theNeomatrix369 @pedromsantos
We are creatures of habit...
@theNeomatrix369 @pedromsantos
..our habits influence our
actions greatly...
@theNeomatrix369 @pedromsantos
Know and accept your
good habits !
@theNeomatrix369 @pedromsantos
Know and accept your
bad habits !
@theNeomatrix369 @pedromsantos
Developer habits is a
very broad subject
@theNeomatrix369 @pedromsantos
But we need to start
somewhere
@theNeomatrix369 @pedromsantos
The TDD life-cycle
@theNeomatrix369 @pedromsantos
Let’s fit it into the TDD cycle
Red-Green-Refactor cycle
@theNeomatrix369 @pedromsantos
The TDD cycle
⇐ apply habits...
Red phase
⇐ apply habits...
Green phase
⇐ apply habits...
Refactor phase
⇐ apply habits...
@theNeomatrix369 @pedromsantos
Refactoring
Developer
Habits:
birth of the #TDD
#manifesto
@theNeomatrix369 @pedromsantos
Original version
@theNeomatrix369 @pedromsantos
Socrates UK 2013
@theNeomatrix369 @pedromsantos
Refining: after discussion 1
@theNeomatrix369 @pedromsantos
Refining: after discussion 2
@theNeomatrix369 @pedromsantos
https://neomatrix369.wordpress.com/2013/09/27
Blog post - Socrates UK 2013
@theNeomatrix369 @pedromsantos
Just before Socrates UK
2016, Pedro and Mani...
@theNeomatrix369 @pedromsantos
Repeat the same exercise
@theNeomatrix369 @pedromsantos
What should stay?
@theNeomatrix369 @pedromsantos
What should be removed?
@theNeomatrix369 @pedromsantos
What should be added?
@theNeomatrix369 @pedromsantos
Should the flow be
improved?
@theNeomatrix369 @pedromsantos
Give more or less
importance to any item?
@theNeomatrix369 @pedromsantos
15-20 minutes
group discussion
@theNeomatrix369 @pedromsantos
Results of the discussions
@theNeomatrix369 @pedromsantos
Shared with the community
Github: http://bit.ly/1tjLS7l
@theNeomatrix369 @pedromsantos
Principles
- tests should test one thing only
- test one logical assertion
- don't mix assertions of state and collaboration in the same test
- modifications of production code should only break related test cases
- each test should be self-contained, including data
- ensure tests are independent of each other
- don't refactor with a failing test
- organise your unit test projects to reflect your production code
- keep your tests and production code separate
- do not use production data and code to test production code
- if your tests are difficult to write or maintain, consider changing the design
@theNeomatrix369 @pedromsantos
Red phase
- create more specific tests to drive a more generic solution (Triangulate)
- give your tests meaningful names (behaviour / goal-oriented) that reflect your
production system
- write the assertion first and work backwards
- see the test fail for the right reason
- ensure you have meaningful feedback from failing tests
@theNeomatrix369 @pedromsantos
Green phase
- write the simplest code to pass the test
- write any code that makes you get to the refactor phase quicker
- it is okay to write any code that you might improve at a later stage
@theNeomatrix369 @pedromsantos
Refactor phase
- refactor aggressively and constantly
- treat tests as first class code
- use the IDE to refactor quickly and safely
- refactor production and test code independently (except changing public
interfaces)
@theNeomatrix369 @pedromsantos
Captured as a mind-map
@theNeomatrix369 @pedromsantos
Does TDD lead to good design?
Find out...
http://codurance.com/2015/05/12/does-tdd-lead-to-good-design/
@theNeomatrix369 @pedromsantos
Discuss with the community
http://SoftwareCraftsmanship.slack.com
channel: #tdd
@theNeomatrix369 @pedromsantos
Big “thank you” to
the first contributors
http://bit.ly/235Ub3a
@theNeomatrix369 @pedromsantos
Q&A
Feedback
@theNeomatrix369 @pedromsantos
Thanks to @jasongorman for
sharing the original list
@theNeomatrix369 @pedromsantos
Thank you!

Refactoring developer habits