Saturday, April 19, 2014

Easily doing things the hard way, or hardly doing things the easy way

A situation came up during a group coding meeting that brought up a design principle that I feel most of us are fairly conflicted on. When attempting to solve a problem, at what point have you spent more time trying to find an easier way to do something than you would have spent doing it the hard way?

The situation was simple, we needed to do a validates_presence_of field for one specific method, not the whole object. The User's avatar did not need to be there for any user page, but it did need to be there for the page we upload the photo on. The solutions we found were large, hack-ey, and difficult to implement, and we thought there had to be another way. There probably is another way, but at the same time, if we spend more time trying to find that way, are we really saving any time? I mean, the solutions we found weren't inefficient, they didn't make unnecessary database queries, or take up a lot of space, they were just difficult to code in and make the code look uglier. In a situation like this one, especially, it's hard to make a call. In production, you might just want to get the thing working and out the door, but in academia, you want to make the cleanest looking code you can since you'll have someone poring over it to find a way to make you lose a couple more points.

I don't really have a decision here, and I don't think there is a decision, really. Different situations warrant different calls.

No comments:

Post a Comment