Posts on test-driven development

published: Thu, 16-Jun-2005   |   updated: Sat, 6-Aug-2016

Here are the articles I've written regarding test-driven development.

Replying to blog post discussing Procedural Thinking

I was browsing through my website logs this evening and noticed that I'd had a bunch of hits from a blog at http://linamishima.livejournal.com all hitting this article of mine on procedural programming. In it, Michelle, the owner of the blog, was pondering that my article was over-reaching because, in the end, all OOP code gets compiled and executed on a "procedural" execution machine, be it machine code on a real CPU or some kind of interpreter. Read more...

Good design skills implies better refactoring

I was pondering this over the weekend. Is refactoring always good? W ith the support for refactoring in C# in Visual Studio 2005 and also Refactor! Pro from those awfully nice people at Developer Express, you'd think life is good. We can refactor all we like, all the time. Read more...

Refactoring != Rewriting

It seems simple enough to me. Martin Fowler spent a long time (as did his contributors and reviewers) to make sure that Refactoring: Improving the Design of Existing Code was a supremely useful reference book as well as a treatise on how to do refactoring well. And, blimey, did they do a bang-up job or what? It's da bomb, in the current vernacular. Every time I open it, I find something new. I've even reread the initial chapters on how to refactor several times and I already feel that it's time to do so again. So why the *&#% do some developers treat the word "refactoring" to mean "rewriting"? Read more...

Object encapsulation and properties

I'm sure we can all rattle off the three tenets of object-orientation without even thinking about it: encapsulation, inheritance and polymorphism. Easy-peasy. I'm sure we could, without even the slightest sheen of sweat appearing on our brow, knock off a quick description of what they mean as well. So why don't we pay attention to them when we write some object-oriented code? Read more...

SourceMonitor

From a post by Dan Miser, I came across SourceMonitor, a rather remarkable tool for developers. It calculates various metrics for source code in various languages, the most important languages for me being C#, Delphi and Java. The breadth of metrics is pretty good too, here the important one for me being cyclomatic complexity. It slices and dices, it's fast, and most impressively of all, it's free. Read more...

Procedural Thinking

Borland have released the latest version of Delphi, known as Delphi 2006. Unlike the two previous releases (Delphi 8—the first .NET version—and Delphi 2005), the news on the street indicate that this one is very good and it has been extremely well received. Like Delphi 2005, it covers 32-bit Windows development as well as .NET development, but unlike Delphi 2005, it's very stable. All kudos must go to Danny Thorpe (who's now moved to Google) and Allen Bauer (who's now Chief Scientist at Borland) as well as the rest of the Delphi and VCL team on such a good product. Read more...

Cry Me A River

A couple of Sundays ago I was in this Starbucks in the mountains, ordering a latte. Behind me in the queue were these two couples, early forties maybe. While I waited to be served, I couldn't avoid overhearing some of their conversation. One of the wives was looking at the mugs for sale and decided she wanted one, possibly as a memento of their visit here. Her husband laughed at her and said no way. She protested, to which he replied "Cry me a river". (Updated: 19-Jan-2006) Read more...

Typing (the programming kind)

There was a time a couple of years ago when I thought generics were the best thing since sliced bread. They still are and the ability of the Anders and C# team to come up with something so amazing as LINQ and lambda expressions for a C# 3.0 preview built on this foundation is pretty amazing. But, in a sense, all these new experimental features gives us is the ability to fake dynamic typing on a static typing foundation. And that leads me to dynamically-typed languages. Read more...

Cyclomatic Complexity

Something that came up in a conversation: what is cyclomatic complexity (CC)? If I gave you a method, how would you calculate the CC of the method from scratch? Actually the second question assumes you know what CC is, so I'm cheating a little. But bear this in mind: managing complexity is an important part of being a good software designer and programmer and CC is a measure of complexity. Read more...

Thread pool (part 2)

Time to start on this little project of mine to design and write a thread pool class. No sooner than I decide this course of action, though, that first, work and my personal life explode (sigh), and that second, Maxx, a fellow architect here shows me Joe Duffy's post on why you shouldn't write a thread pool, or, rather to be fair, why many people's reasons for doing so are not valid. Hah! I shall forge on since Joe's argument is mostly about performance. Nevertheless, I shall bear his posts on multithreading in mind as I TDD myself to a solution. Read more...

Thread Pool (part 1)

So a reader commented about my WaitableThread class. "Couldn’t you use a custom thread pool for this?" and encouraged me to take a look at a "smart" thread pool on Code Project. As it happened, the one he was recommending was one I'd taken a look at previously. Yes, you see the developer who wanted to launch lots of threads (see my previous post) had discovered this implementation and was all for using it. I took a look at it and decided that I could see enough problems on a cursory examination that I didn't want to use it for real code. Hence, the effort to write a WaitableThread class. Read more...

Why BDUF can be bad

So quick as a flash after I'd posted my last post (KISS TDD hello), an ex-coworker wrote "While I appreciate your thoughts on TDD, you seem to dismiss BDUF [Big Design Up Front] as being unnecessary. [...] Seems to me that SOME DUF is necessary to keep the TDD in some frame of context, no?" Read more...

KISS TDD hello

There's a lot of chatter in the blogosphere at the moment about Microsoft's ill-advised attempt at rewriting TDD (now generally known as MSTDD). I wrote about it myself in this post when I was feeling depressed about the uptake of TDD here at work. But now the Big Guns (tm) of the test-driven development movement have been coruscating Microsoft for what is, admittedly, a blundering attempt at calling a waterfall methodology TDD. (There's a great series of posts by Scott Bellware on his blog about all this debacle.) [Update Wed 23-Nov-2005: MSDN has now removed, er, retired, the article. 416 people had voted on it for an average score of 1.19.] Read more...

More on TDD depression

Holy cow, I seemed to have struck a nerve with my previous post. Read more...

TDD depression

Over the past year or so, I've become more and more aware that the big companies that provide development tools just don't understand test- driven development (TDD). In fact, I'd go even further, a lot of companies that write software don't seem to get it either. So, I'm depressed. (Updated Tue 18-Oct-2005) Read more..

Using the Singleton pattern (part 1)

Whenever a couple of developers have a chat about Design Patterns next to the water cooler, the conversation is almost guaranteed to turn to the Singleton pattern. In fact, when two Delphi developers discuss Singleton, it's like they are talking about two different languages since Delphi can't do the basic trick of making a Singleton work. But no matter which language the developers use, they'll always talk about the implementation of it. Never, it seems, do they take a step back and wonder if Singleton is a "good" pattern to use. Read more...

What does TDD help you do?

This is a bit of a trick question. Many developers when they come across TDD (test-driven development) for the first time assume that it is a technique for writing quality code. Well it certainly looks that way: you write the test and then you write the code to pass the test. Refactor a bit to get rid of duplication, and, bam, you get well-tested code of high quality and furthermore, as a side-benefit, 100% code coverage. Not bad, eh? Read more...

Some thoughts on TDD and the Strategy pattern

At one of the Birds of a Feather sessions at Tech*Ed, someone said something to the effect that you aren't doing TDD until you understand the Strategy pattern. That was both fascinating and coincidental since I was only recently contemplating the use of the Strategy Pattern (or the Policy pattern as it's sometimes known) in some OO design work. Read more...

Using TDD when you don't know the technology

This came up in a discussion at work. "We need to write code to access technology X, which uses COM. How do we do it using TDD?" Technology X is very deep and rich and looking at the API is an exercise in frustration: how to we get to where we want to be? The task seems overwhelming. Read more...

Testing in isolation

One of my current projects is writing unit tests for a body of code. It isn't germane to this discussion why these unit tests weren't written from the get-go; let's just accept that the code 'works' but that it's getting to the stage where it's becoming brittle. The client just wants proof that the code works. Read more...

Some answers on TDD

In which I answer a few general questions about how I use Test Driven Development (TDD) in my own work. Read more...

Thoughts on tools that help you refactor

I've just finished a small contract in C#. In doing it, I relied on one methodology, TDD, and three tools, NUnit, NUnit Addin, and C# Refactory (apart from Visual Studio of course). Learn how it went. (Updated with new Delphi info.) Read more...

Implementing interfaces and using TDD

Sometimes in TDD (Test-Driven Development), you find yourself having to implement an interface. At this point, you have to implement all the interface's methods, a clear violation of what TDD stands for. How do you get around this? Here's my technique. Read more...

TDD and private methods

A question that came up recently in my coding: if you use TDD (Test-Driven Development) to write code, should you be writing tests for private methods and hidden classes? Read more...

Testing quicksort

Recently I was in an e-mail conversation with a reader of my book. He was trying to implement quicksort in a class of his devising using the implementation from the book. He was running into a problem where it wasn't sorting properly. Read more...