thoughts from brian samson

The worst comment I’ve ever written

I’m sitting here trying to debug a very complex piece of “meta” code. This code generates web forms that have fields that automatically show/hide based on the selections in other fields. It’s usually very nice to work in, and it makes creating dynamic forms easy, but it is insanely complex under the hood. I finally find the source of the bug is a hip, railsey, ruby one-liner. It’s not to hard to figure out what that line does (adds some kind of prefix to each key). However I have no idea why it would do that. Luckily when I wrote this code I knew this was confusing, so I included a comment:


if (@if)
#in case this is being rendered in a subsection, the key
@if.each {|andor, array| array.each {|h| h[:key] = field_name_prefix + h[:key] }}
end

Except I forgot to finish it. The key…. the key….. WHAT ABOUT THE KEY YOU IDIOT?? This is the worst comment I’ve ever written. It is worse than no comment. No comment wouldn’t have got my hopes up….and then crushed them. Why isn’t it lunch time yet?

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.