Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Model Naming: Fix or Leave As-Is

This is more of a philosophical question than a technical one.

I'm about 40 hours into working on a new Rails app. It's retail-related, and early on I chose the name "item" to describe a single available product for sale.

As time has gone on it's become obvious to me this was a mistake - the word "item" is too generic, and "product" perhaps would have been a better choice.

So the decision I'm faced with now is, do I refactor / rename my models, ERB code and tables before I build more with this somewhat poorly chosen name, or do I just leave it as-is, save some time and move on? I worry that it's choosing the latter repeatedly that results in the ridiculous technical debt I've seen on other projects, but I also think this might be a form of premature optimization.

Thoughts?

like image 381
tomkarlo Avatar asked Mar 07 '11 17:03

tomkarlo


1 Answers

Naming convention is absolutely necessary for mid-to-large projects. I would say go in and refactor everything to make the naming as specific as possible. Generic identifiers will quickly get out of hand as new functionality gets introduced (I was once on a project that had a class named UserReportReportReportParameters).

The quicker you get this done, the less painful it will be.

Edit: I should probably add that if this is impossible due to deadlines or any other constraints, to stick to the current naming schema until you have time to refactor everything at once. I'm of the firm opinion that a bad naming convention is better than a mixed naming convention.

like image 127
Chuck Callebs Avatar answered Oct 12 '22 01:10

Chuck Callebs