Editorials

A Question to Improve Your Code

Is it testable? That single question has impacted my software writing more than just about any other software development strategy. If the tests are automated it is even more important to me. The impact of writing testable code has many facets:

If you want to write automated tests efficiently you have to keep the testable methods simple in order to accurately cover the requirements of the method.

Smaller methods that are fully testable reduce the amount of time needed to get your software bug free.

Many of the principles of software development may be implemented by default when you write testable software. Principles such as single responsibility or encapsulation arise naturally.

So, in my opinion, writing testable software has the additional benefit of implementing good software development principles. I find this more difficult to implement in SQL code. Breaking work out into separate components can make the software more difficult to understand and maintain, and often has performance implications.

Even still, I find it valuable to create automated tests for SQL Code. It doesn’t result in as many additional benefits as code written in procedural or object oriented languages.

What is your position on testing? Have you experienced additional values from using tests? Share your thoughts here or by email to btaylor@sswug.org.

Cheers,

Ben