Pursuing Elegance

Pro­gram­ming is get­ting paid to do puz­zles. Some are harder than oth­ers, some are put the cylin­der in the round hole level of dif­fi­culty, oth­ers near MENSA level chal­lenges. Over the past few days I’ve been try­ing to fix an issue which amounted to numer­ous hours try­ing to bang out a solid solu­tion, in the end I went with the less ele­gant solution.

I’ve tried explain­ing this a few times now and the peo­ple I dis­cuss it with seem uncon­vinced, and per­haps it’s this feel­ing that makes me a true pro­gram­mer, but I feel that the solu­tion that works isn’t the same as a solu­tion that’s right.

To avoid the deep details of the prob­lem I faced, I’ll use a metaphor: If you had to take apples from one bar­rel and put them in another, how­ever you only want ones which are red, were picked after Sept. 1st, have no bruises and are sweet in taste.

Would you rather pick the right ones from the start? Or pick mostly the right ones, then go back through the bar­rel and find the ones that slipped by? The first is what I wanted to do and spent many hours try­ing to do. The lat­ter is what I ended up doing because it had become nec­es­sary to get a solu­tion and move on.

I’m still test­ing this code, we want to be sure it only removes bad entries (apples) rather than all the bad entries and a few good ones.

At least it’s a solu­tion for the time being. I’ll come back to it later.

Discussion

No comments yet, be the first.

Add a Comment

*

* Copy this password:

* Type or paste password here:

*