Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2016/02/15

Notes on a Refactor

I prefer to let sleeping dogs lie. There's old, bad code that could be improved, but there's no case to be rewriting old code unless there's a problem with it that breaks a thing. Call it Bug-Driven Development, if you will.

But every bug will have it's day, I suppose.

My lab does science, and in order to not do wasteful, expensive science on things not worthy of the time and money, we do quality assurance, and we display the output to show us and our clients whether the samples are worth using or not. I wrote code to take the output and put it into a form to put online where our techs and our clients can see and use it.

And it sucked.

It sucked, in part, because I have two loops, one to find which GEL image to deal with and one for the EGRAMs. I pull everything into one loop, using grep() to find which GEL and EGRAM to pull for any point.

When I wrote the old code, things like map() and grep() were foreign concepts, and I might think twice about using them if I felt there was a chance that a programmer that wasn't me would have to maintain this code. The new solution is not so much shorter, but I feel it is more straightforward.

It could be better. I felt the call, for example, to redo this in Template Toolkit, pulling away from CGI.pm, but that struck me as a waste until we move forward on a wholescale transfer from CGI to Dancer or another framework.

Anyway, here's the code.