K
khaines
Some time in the past, I wrote a line of code.
It looked like this:
if pu : pu = pu.url.to_s != '' ? pu : nil end
There is sat, working fine, for a long time. Today, I was editing the
code, doing a variation on it for a new site.
I came to that line.
I looked at it.
I called it stupid.
Sure, it's concise, but what did I gain by making it so concise over
making it so that it was clearly readable a year and a half later?
Not much.
Sometimes clever is good, when there is a reason for it. However, that
time, clever was just plain stupid.
Kirk Haines
It looked like this:
if pu : pu = pu.url.to_s != '' ? pu : nil end
There is sat, working fine, for a long time. Today, I was editing the
code, doing a variation on it for a new site.
I came to that line.
I looked at it.
I called it stupid.
Sure, it's concise, but what did I gain by making it so concise over
making it so that it was clearly readable a year and a half later?
Not much.
Sometimes clever is good, when there is a reason for it. However, that
time, clever was just plain stupid.
Kirk Haines