Don't Just Jump In and Code. Ever

Obvious statement; programmers are, at their core, are problem solvers. Yes, our output is code, but at the base level the entire process of creating the code is in response to some sort of problem. On top of that, once the initial problem is solved we're still responsible for fixing new, unknown, issues when they come up.

Solving problems is what we do. I was reminded of this the other day when a bug was logged about a project I'm working on.

The issue was that the tab ordering on a form, where you use the tab key to move between fields in a form, was skipping the select fields in FireFox on a MAC. Since I wrote the program the issue was reported in so the responsibility for fixing it fell to me.

Now, how would you solve the issue?

Assuming you took exactly the same path I did, you would probably attempt to replicate the issue and found that, yes indeed, when tabbing between fields in a form the order for the tabs was unreliable; it would skip all the select boxes. Seeing the proof, you might start looking into what could be causing it.

Immediately, all sorts of suspects come to mind:

The field "label" elements could be wrong.

The divs the fields are placed in are out of order

FireFox could just be broken (hey, it does happen)

As do a couple "simple" solutions that remove the issue without technically fixing the problem:

Set a dedicated "tabindex-n" in each field element. This could force the tab flow but it's not known if it will fix the issue .

Write FireFox specific JavaScript to force the tab order in that browser (costly but certain to fix)

You now sit at a crossroads of sorts; you can figure out why tabbing isn't working by eliminating suspects or you can attempt to bypass the issue entirely and use one of the above "simple" solutions or you take door number #3 and do more research on the issue before making a decision on direction.

We've seen it time and time again; programmers eager to just jump in an start changing things, writing things, and just creating things. This is always, 100% of the time, no excuses, unequivocally the wrong move.

Doing, just basic, research on the issue produced this gem from CoolWeblog:

I just spent the better part of an hour trying to get tabindex to work under Firefox/Mac OS X.

1 Comments

Having to solve problems in code I was responsible for writing is one of my biggest fears. I’m sure I’ll get used to it once I’m coding in the real world, but as it is we don’t really get much experience with that at uni.

You provide a really good example here of why jumping in and coding right away isn’t the best thing. I find even with non-coding problems a quick search can provide a solution that is quicker than anything else I had planned to try.