Upside-Down Problem Solving

In doing Sudoku puzzles, most of the time the next solution is staring you in the face. But you can’t see it for all the other numbers in the way.

I got stumped on a puzzle Saturday, one that I’d stared at for about ten minutes without success. I have a ten-minute rule, so it was time for a new tack. (Others might call this ADD, but I follow Weinberg’s Bolden Rule: “If you can’t fix it, feature it.”) I turned the book around to let my son look at it, but continued to look at the upside down numbers. Thirty seconds later, the very obvious solution almost started blinking at me. Duh.

Often, all we need is a different perspective on the problem. Many of us have experienced code enlightenment when having someone read over our shoulder. The usual explanation is that we’re now trying to perceive how others are reading our code. Another thought: Sometimes I suspect that a very brief mental break is all that’s needed.

But maybe it’s just that we’re shifting in our chair and catching the code at an odd angle. 🙂 Next time I’m stumped on code, perhaps I’ll invert my display. Or change my font.


When I’m really stumped I take a hot bath, put on some nice music, and watch the nice rubber duck float by. It’s never failed to evoke an epiphany or two however there’s a downside; this practice tends to raise an eyebrow or two in open workspaces. Also the office rugs tend to get wet.

Looking at things from another point of view (and even being ABLE to see alternate POVs). There used to be a great book out called ‘A Whack on the side of the head’ – basically techniques to unfetter our imaginations and see possibilities where none previous seemed to exist. Hmm.. I need to see if I can find my copy.

In the mean time..ummm, can somebody pass the soap please?

They need to make waterproof laptops…

Dogs and Bugs

My dog kept wandering around the neighborhood, so I recently put up a fence around my back yard. Now I’m experiencing some regret: after all that expense and effort, the dog no longer gets out of the yard! Was it all a waste of time?!!?

(I think Ward Cunningham puts it much more nicely, but hey, I’m not Ward and will never be. Ward says, “How about FIND BUGS PROMPTLY?“)

TDD Hype

A trend I’ve noticed in the software development community is that there are a large number of developers who resist the new wave. Many of those who spent their formative development years doing procedural development went kicking and screaming into the OO age; some suggested that it was an inappropriate tool for many problems. Many C++ developers looked at Java as a toy, not useful for any real work. And I’ve met enough Java developers who thought that Java was the last word in programming languages.

Certainly we should question newfangled tools and techniques, and insist on putting them through their paces. OO is not the best tool for every problem, Java did suck big time when it first came out, and yet there are now some significant advantages to continue doing business with it. Challenges ultimately help the tools & techniques improve.

Experimentation and innovation is at the heart of the software industry, not active resistance. But it’s far easier to sit in a corner and make as many possible excuses for not doing something. I know, because I’ve done so myself. There are plenty of jobs out there using old technologies, and places where people are happy with the status quo.

So, TDD. Some of us strongly believe in it, only because we’ve seen benefits firsthand–not just from toy Stack examples, but from working on systems that range from tens of thousands, to hundreds of thousands, and millions of lines of code. Ahh, but the stack example is all the people sitting in the corner see, because that’s all they want to believe is behind TDD.

I agree with the vocal dissenters that TDD should not always be used, but not for the lame list of excuses they often come up with. Primarily, the reason is that the typical American software team just isn’t that good. TDD is a reasonably tough discipline to get a handle on, and most developers are still struggling with OO, language, and tool basics.

What’s interesting is that TDD would ultimately help these people the most–some of its best potential is its use as a learning tool. The vocal dissenters, on the other hand, are usually reasonably sharp developers who already have a good notion of design. Thus they can’t quite understand why a technique that promotes more decoupled and cohesive designs is important–“duh, we already get it.” Particularly, for example, if they don’t happen to work with lots of typically underachieving coders.

Is TDD overhyped? Not a chance. There are still mountains worth of learning that TDD will promote in the minds of the majority of the developers out there. For those who don’t want to do TDD, don’t do it.

Can TDD be dangerous, and lead to disasters? Yes. This is true for any tool in the wrong hands. That also includes insisting on emphasizing test-after–I’ve seen that lead to plenty of failures and wasted time. TDD, like OO or any other tool/technique, is not for everyone or every project. But in the right hands, I’ve seen TDD work wonders on software projects.



I agree … that TDD should not always be used.

Jeff, this statement puzzles me. While I agree that it’s quite possible to create high-quality software without TDD, and equally possible to create crap while using TDD, I can’t really think of a situation where I think TDD should notbe used.

Maybe I’m just misunderstanding your point.

Hi George, thanks for the comment. In the sentence starting “Primarily,” I’m alluding to the fact that if you don’t have the discipline or desire to do TDD right, then it can cost you more than not doing it period. This is based on a number of experiences working with teams who viewed TDD as someone else’s (usually a VP’s) checklist item. The tests they produced were terrible, unmaintainable; ultimately they fell into disuse as programmers made excuses as to why they couldn’t worry about them.

I agree, there aren’t any (applicable) technical applications for which I feel TDD should not be used. (Applicable meaning OO and other languages for which xUnit support exists.) TDD does have its weaknesses around driving in threading, and deriving (not implementing) algorithms, but that’s usually (and should be) a tiny fragment of most apps.

Jeff, that makes sense. Just going through the motions of anything is a waste of effort.

I’m just musing here but sometimes I wonder whether this is a skill that CAN be learned by everyone Jeff. Some people seem wholly incapable of mastering the abstractions necessary to develop decent OO code. Perhaps some people have a similar problem integrating TDD into their habits? Ironically, for those who struggle with mastering OO abstractions, TDD would seem to provide a basis for improving their code; it promotes SRP since it’s darned hard to test a new 500 line method.

It would be interesting to list all the arguments against TDD and engage in some honest inquirey into the mental models behind the objections. It’s important to remember that there is no such thing as a ‘best’ practice; there are only better practices within a given context.

Hi Jay–Thanks for the comment!

There are some postings out there (and other resources) where you can find people posting objections, but I think many of them are dishonest. Beust, for example, posted a long list of reasons why TDD was bad on JavaRanch a few months ago, and he spends time in his recent book railing against it. Most of the reasons came across as a smart someone who just wants excuses to keep doing things his way.

There are also the two articles in Better Software, in which I find some of the debate reasonable, and other claims simply ridiculous or ignorant.

I agree that TDD is probably a skill that some people aren’t capable of learning, like OO. But I think most sharp developers can learn it–if they really want to. I tend to fall on the harsher side of “this stuff (OO or TDD) isn’t really that hard,” and maybe people for whom it *is* too difficult should find a better-suited position.

Ultimately it gets down to the question, “Are we writing software that’s easy to change?” Changing code safely without tests is hard. Writing tests after the fact is usually a pain. As the old saying goes, anybody can write software that a computer can understand. Until the value of intrinsic quality is more widely embraced, we’re going to see a perpetuation of very bad code written by people better suited to other contributions to society.

I think it’s important to make this point again though; any discussion of whether a practice is better or not is meaningless without a context. ‘Better for WHOM’? is an important question to ask. For example – for somebody who can instantly construct a galaxy of classes and their relationships in their head without benefit of tests – it’s going to seem a waste of time.. particularly if they work in a development shop of one. To the poor suffering soul who has to maintain or change code spun by such geniuses, the answer may be quite different.

Great point, and one that I’ve alluded to before. Beu*t says that others shouldn’t bother with TDD for its design benefits, because *he* is already good enough with respect to creating clean designs. Maybe he is one of the rare few, but the problem is that he imagines that everyone else is capable of thinking at that same level.

Maybe working in a fantasy land like Google quickly takes you out of teach with reality.

Choices, Choices

Who else has this quandary?

I’m long, long weary of Java and C++ (which I thought I had been weary of over well over a dozen years ago, but here I am again struggling with it). Where next? Sure, I’ve been looking at Ruby for over five years now, and Rails a bit as well, but I’ve not had an opportunity to put it to any real use in a production environment (except for an odd pairing session here and there).

Recently I’ve also looked at D, Erlang, and Scala. “Looked at” means that I’ve downloaded it, gotten it running, run through at least a tutorial or two, maybe read the book, and then moved on to experimentation, perhaps starting to re-implement pieces of systems.

Seems like the most interesting stuff happening is going on in Ruby–it’s a rapidly maturing environment. There are things going on around the other three languages I mentioned, but it doesn’t to be nearly as much. Maybe when they’ve reached “critical mass,” there will be more going on around them.

In any case, there are scads of new languages and tools vying for attention. It seems like there are more than ever, making for an exciting time. It also means that my stack of what I don’t know keeps piling up. I think I need to pick one and invest some real, significant effort into it.

So, the decision: ride on the bandwagon, or blaze a trail? What are your reasons for putting your money where it currently is? What else should I be looking at that I’m not?


You left out groovy, which allows you to re-use all of your Java knowledge, and combine that with some Ruby-like functionality all on the JVM.