Pursuing Elegance

Programming is getting paid to do puzzles. Some are harder than others, some are put the cylinder in the round hole level of difficulty, others near MENSA level challenges. Over the past few days I’ve been trying to fix an issue which amounted to numerous hours trying to bang out a solid solution, in the end I went with the less elegant solution.

I’ve tried explaining this a few times now and the people I discuss it with seem unconvinced, and perhaps it’s this feeling that makes me a true programmer, but I feel that the solution that works isn’t the same as a solution that’s right.

To avoid the deep details of the problem I faced, I’ll use a metaphor: If you had to take apples from one barrel and put them in another, however 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 barrel and find the ones that slipped by? The first is what I wanted to do and spent many hours trying to do. The latter is what I ended up doing because it had become necessary to get a solution and move on.

I’m still testing 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 solution for the time being. I’ll come back to it later.