Tuesday, March 31, 2009

15 Helpful Tips from Scott Bellware's Behavior Driven Class

On March 24th, last Tuesday, I attended Scott Bellware's helpful seminar on "Test-Driven Development and Behavior-Driven Development". A few of my take-aways:

  1. One bug takes a unit of time to fix, but with multiple bugs the time goes up exponentially since the bugs can interact. Moral: Code in steps and only introduce one bug at a time.
  2. Ask if the test you are about to write is a valuable test.
  3. Code-DB impendence mismatch example: If orders have links to customer in the db, in code the customer has links to the orders.
  4. Using "static" methods between layers is bad, it's like welding the objects together.
  5. Inheritance is strong coupling, to be used as a last resort.
  6. Scott and his team removed an entire layer of testing when they realized it provided less value than it took to maintain.
  7. Databases are places for dead objects, not logic.
  8. Someone at the meeting said Microsoft doesn't really do domain applications like we do, so they cannot really offer much advice on how to code.
  9. "Reuse" is not a good goal.
  10. You can overwrite tests, simple things are tested in more complicated tests.
  11. Don't use prepopulated databases with test data. Start with an empty database, and end with an empty database.
  12. When Scott asked the participants "Who does unit testing?" 80% of the 25 people raised their hands. "Who uses MSTest?", one hand.
  13. Regression tests are a side effect of Test Driven Development, not the primary goal.
  14. Doing traditional OO analysis (nouns, verbs,...) creates more objects than needed.
  15. Don't directly expose an object's collections; use helper functions on the object. (Use Customer.Add(obj) instead of do Customer.list.add(obj))

No comments: