DRY(a): Year After Year
I’m guilty of it. Many of you are likely guilty of it… and I know that several customers of our Rails Code Audit and Review service are guilty of it.
How many times have you realized (after a few months has passed) that your Copyright date/year on your web site was no longer current?
How many of you had the same problem last year? The year before?
Let me share some advice with you all… DRY (a)!
Don’t Repeat Yourself (again)!
This is really a simple problem to fix but when we’re busy tackling bigger problems… little things like this slip by. Don’t worry, you’re not the only one who was reminded by a colleague three months into the year that you forgot to update this.
On client projects, we have a handful of helpers that we drop into the application. We’re starting to extract more of these into plugins and will be releasing those as time permits. It just happened that I found myself looking at yet-another Rails code base this afternoon that was showing 2007 in the footer. An easily forgivable offense.. but if you’re going to go in there and change it (again), take a moment to do the right thing. ;-)
Our solution at Planet Argon on client projects is to create a basic view helper that renders the current year. This allows us to do the following.