Kent Beck’s Rules of Simple Design #1

Sean Coates
Aug 27, 2017 · 1 min read

The code must run all the tests.


This makes refactoring safe. This is one of the most important things, as it allows future people to come in and alter or expand the code safely. One of the most common sources of bugs in codebases that aren’t covered by tests is to have a new feature unintentionally break existing functions.

The tests communicate the design. When the tests are written well, they lay out the plan of what code will be necessary to implement the feature.

The tests describe the desired behavior. Tests shouldn’t simply prove that a function does what it is supposed to do. They should be worded in such a way as to tell the reader what the desired behavior is.

The tests tell you when you are done. Don’t write code that isn’t needed to satisfy the tests. Don’t write code in anticipation of features that haven’t been requested. You aren’t going to need it (YAGNI).

)

Sean Coates

Written by

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade