Scripting News, the weblog started in 1997 that bootstrapped the blogging revolution...
I had a working Find command, but needed to factor the code so that I also had Find again. One has a UI, the other just repeats the previously specified search. The code that does the finding should be the same in either case. Splitting off common code is called factoring.
After factoring, I tested the Find command. It works.
Getting ready to test Find again, I paused, thought to myself -- there's a chance it might work the first time. Bad idea. Of course it didn't. No big deal, I'll just step through the code, watch it fail, and figure out what needs fixing.
I notice a value is undefined. Weird. I repeat the experiment and watch it get its value. It's calling a routine that's been called millions of times. It works as well as anything. I seriously doubt it has any bugs. But there it is returning an undefined value.
It never occurred to me to check if the thing I'm asking for actually is undefined.
Two hours later it finally dawned on me, that was the problem. I had been assuming undefined was the wrong answer. It was the right answer. There was an edge case which I was hitting now, which had nothing to do with the Find command, that was causing the value to be undefined. I added a bit of code that checks for the condition, and fixes it, and voila, it all works.
Moral of the story, the bug was available to be discovered within minutes, had I just asked the right question.
The hard part of doing Find in a browser-based app is figuring out how to reliably get the keystrokes for Find and Find again, Cmd-F and G respectively.
The browser has its own Find, but an outliner like Fargo really needs to do it for itself. The browser doesn't know about text that's tucked away under collapsed headlines, for example. And it shouldn't be searching the menus and the text in the right margin.
It works well in Chrome and Safari, problems in Firefox.
This is something the browser guys should get together on, imho, if there's going to be a browser-based apps ecosystem.