Wednesday, July 9, 2008

Throwaway Code Should Be Fun

Rails question: can I define a class inside a controller, and then use it in a view?

Turns out I can.

I know some people who are like, oooh, that's unprofessional, but there's actually a huge advantage here. You're not going to look at code like that and go, hmm, is that an important part of the application? If it ever gets accidentally included in a commit, somebody will notice quickly and fix it.

Plenty of projects have code accidentally committed for a long time before somebody spots the flaws. That won't happen here; the code sticks out like a sore thumb.

It's a lot better to look foolish than be foolish.