Blog Archive
All Tags
Our people weigh in on the issues of the day.
Blue Slate's people think a lot about the challenges facing their industries today. In the process, they often come up with completely unexpected slants on current issues, or new ways of thinking about business problems. Bluespeak is where they share those thoughts. Feel free to read and reflect.
[Any views or opinion represented in this blog are personal and belong solely to the blogger and do not represent those of Blue Slate Solutions.]
Michael Delaney, a senior consulting software engineer at Blue Slate, commented on my previous posting.
As I created a reply I realized that I was expanding on my reasoning
and it was becoming a bit long. So, here is my reply as a follow-up
posting. Also, thank you to Michael for helping me think more about
this topic.
I understand the desire to rely on unit testing and its ability to find issues and prevent regressions. For TDD, I’ll need to write separately. Fundamentally I’m a believer in white box testing. Black box approaches, like TDD, seem to be of relatively little value to the overall quality and reliability of the code. Meaning, I’d want to invest more effort in white box testing than in black box testing.
I’m somewhat jaded, being concerned with the code’s security, which to me is strongly correlated with its reliability. That said, I believe that unit testing is much more constrained as compared to formal reviews. I’m not suggesting that unit tests be skipped, rather that we understand that unit tests can catch certain types of flaws and that those types are narrow as compared to what formal reviews can identify.
[Read More]Tuesday October 18, 2011 | By David Read
Code Reviews Trump Unit Testing , But They Are Better Together
Last week I was participating in a formal code review (a.k.a. code inspection) with one of our clients. We have been working with this client, helping them strengthen their development practices. Holding formal code reviews is a key component for us. Part of the formal process we introduced includes reviewing the unit testing results, both the (successful) output report and the code coverage metrics.
At one point we were reviewing some code that had several error handling blocks that were not being covered in the unit tests. These blocks were, arguably, unlikely or impossible to reach (such as a Java StringReader throwing an IOException). There was some discussion by the team about the necessity of mocking enough functionality to cover these blocks.
Although we agreed that some of the more esoteric error conditions weren’t worth the programmer’s time to mock-up, it occurred to me later that we were missing an important point. What mattered was that we were holding a formal code review and looking at those blocks of code.
[Read More]Wednesday October 12, 2011 | By David Read | Comments[2]
Domain Testing at the Unit Level, Part 1: An Introduction
It is surprising how many times I still find myself talking to software teams about unit testing. I’ve written before that the term “unit testing” is not definitive. “Unit testing” simply means that tests are being defined that run at the unit level of the code (typically methods or functions). However, the term doesn’t mean that the tests are meaningful, valuable, or quality-focused.
From what I have seen, the term is often used as a synonym for path or branch level unit testing. Although these are good places to start, such tests do not form a complete unit test suite. I argue that the pursuit of 100% path or branch coverage and the exclusion of other types of unit testing is a waste time. It is better for the overall quality of the code if the unit tests achieve 80% branch coverage and include an effective mix of other unit test types, such as domain, fuzz and security tests.
For the moment I’m going to focus on domain testing. I think this is an area ripe for improvement. Extending the “ripe” metaphor, I’d say there is significant low-hanging fruit available to development teams which will allow them to quickly experience the benefits of domain testing.
First, for my purposes in this article what is unit-level domain testing? Unit-level domain testing is the exercising of program code units (methods, functions) using well-chosen values based on the sets of values grouped, often, by Boolean tests in the code. (Note that the well-chosen values are not completely random. As we will see, they are constrained by the decision points and logic in the code.)
The provided definition is not meant to be mathematically precise or even receive a passing grade on a comp-sci exam. In future postings I’ll delve into more of the official theory and terminology. For now I’m focused on the basic purpose and value of domain testing.
[Read More]Tuesday February 01, 2011 | By David Read
Fuzzing – A Powerful Technique for Software Security Testing
It is unexpected input that is useful when looking to find untested paths through the code. If someone shows me an application for evaluation the last thing I need to worry about is using it in an expected fashion, everyone else will do that. In fact, I default to entering data outside the specification when looking at a new application. I don’t know that my team always appreciates the approach. They’d probably like to see the application work at least once while I’m in the room.
These days there is a formal name for testing of this type, fuzzing. A few years ago I preferred calling it “gorilla testing” since I liked the mental picture of beating on the application. (Remember the American Tourister luggage ad in the 1970s?) But alas, it appears that fuzzing has become the accepted term.
Fuzzing involves passing input that breaks the expected input “rules”. Those rules could come from some formal requirements, such as a RFC, or informal requirements, such as the set of parameters accepted by an application. Fuzzing tools can use formal standards, extracted patterns and even randomly generated inputs to test an applications resilience against unexpected or illegal input.
[Read More]Friday January 21, 2011 | By David Read
Design and Build Effort versus Run-time Efficiency
I recently overheard a development leader talking with a team of programmers about the trade-off between the speed of developing working code and the effort required to improve the run-time performance of the code. His opinion was that it was not worth any extra effort to gain a few hundred milliseconds here or there. I found myself wanting to debate the position but it was not the right venue.
In my opinion a developer should not write inefficient code just because it is easier. However, a developer must not tune code without evidence that the tuning effort will make a meaningful improvement to the overall efficiency of the application. Guessing at where the hotspots are in an application usually leads to a lot of wasted effort.
When I talk about designing and writing efficient code I am really stressing the process of thinking about the macro-level algorithm that is being used. Considering efficiency (e.g. big-O) and spending some time looking for options that would represent a big-O step change is where design and development performance effort belongs.
For instance, during initial design or coding, it is worth finding an O(log n) alternative to an O(n) solution. However, spending time searching for a slight improvement in an O(n) algorithm that is still O(n) is likely a waste of time.
Preemptive tuning is a guessing game; we are guessing how a compiler will optimize our code, when a processor will fetch and cache our executable and where the actual hotspots will be. Unfortunately our guesses are usually wrong. Perhaps the development team lead was really talking about this situation.
[Read More]