Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we put units of measurements in attribute names? [closed]

I think most of us agree that it's a good idea to use a descriptive name for variables, object attributes, and database columns. If you want to store something's name, you may as well call the attribute Name so people know what to put in it.

Where the unit of measurement isn't immediately apparent, I think you should go a step further and include the unit of measurement in the name. Length_mm, for example, should help remind developers that they'd better convert the length to mm if the user just entered it in inches.

My database administrator, however, just told me that including units of measurement in database column names is “frowned upon”. I think that's just nuts, but perhaps there's some risk DBAs know about that I don't.

Throw me a line, here: should we embed units of measurement in our attribute names? Why? Why not?

like image 832
Garth Kidd Avatar asked Jan 15 '09 00:01

Garth Kidd


1 Answers

If you have a consistent UOM for things, then your DBA's policy is OK.

For example, if timespans are ALWAYS in minutes, etc.

If the UOM could change, then you should store it in another column, alongside the qty.

That said, I tend to side with you on this. Clarity trumps most things, including this. I'd rather see DurationMinutes than Duration and have to guess what the UOM is.

like image 117
Michael Haren Avatar answered Oct 02 '22 11:10

Michael Haren