I just finished a 3-day TDD course with Roy Osherove. Here are some of my lessons.
The simple rules for TDD are:
- Write a test that fails.
- Make the test pass.
- Refactor.
By following these rules I will also do:
- Investigate the problem domain, but not more than necessary, and make sure the assumptions are right.
- Implement code that works.
- Implement the right code.
- Start with a simple thing, that can be finished within short time, at least within a sprint.
- The development cycle will have small incremental changes, rather than larger code chunks which is harder to test.
- Decide when to do state-based testing and when to do interaction-testing.
- Do test reviews.
Other things I will do:
- Address legacy code with TDD.
- Consider not doing TDD, but right now TDD feels simpler than not doing TDD. Even though TDD is hard.
- Separate unit tests and integration tests.
- Do pair programming.
- Write more integration tests.
- Start learning code contracts (C# 4.0).
- Start learning specification by example and write acceptance tests.
- When I have made a new system, or learned a legacy system, I will make a video describing it
- Write down the coding conventions.
Other things I learned from Roy:
- How to learn things, and what ravines and plateaus are. (This is a part I feel need even more investigation, but not now.)
- Go mouse-less.
- Do coding katas for training. (I have already been doing this after the course, and will continue).
So TDD addresses the understanding/misunderstanding of issues by forcing you to make assumptions and implement the right code. Make it your choice to do it!
Ingen kommentarer:
Legg inn en kommentar