Follow the example.

It pays to write good examples.

As you deal with reviewing software and comparing the results to realistic business scenarios, you will start to collect a series of example situations. These examples address many “what if” questions that come up as people learn how the system should behave under various conditions. A good practice is to document these examples into the tests that cover the code.

When it comes time to refactor the code or add new functionality to the system, it will be quite beneficial to have these examples in place. With the expected behavior modeled in tests, you can be more confident that any change to the software still meets the requirements of all of the examples that have been documented so far.

Although writing tests for each example may be a significant amount of work, the benefits of being confident about the quality of the product are enormous. It’s certainly worth the effort. If you can’t be bothered to write tests, you can’t be trusted to refactor the code.

Be sure to find examples that cover the edge cases. It’s quite common for an incorrect algorithm to appear to function for ordinary data but get the wrong result in certain edge conditions.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: