In Ruby and some other languages, type is a reserved keyword. I often find myself a bit tripped up by this because I often want to assign “types” in one way or the other. type_of or perhaps category are others.
I want to expand my vocabulary. Thanks.
Latest comments (26)
Used in French to mean "kind of" / class / type.
Not an answer, but where are you seeing
typeas being reserved in Ruby? It's discouraged in Rails as it's used by default for STI, but if you want to go against the grain you can even override that.Like others I tend to agree that more context is needed to come up with the right word. To me
typejust means "type of class." If we're talking about something else then other words are useful, but generically.. oof.. tough to say.typeis the best term I know. I go even further and name integer fields with a reference to another table (forgeign keys) like*_type_id.For example.
addresses.address_type_idorcustomers.customer_privacy_type_id.In Elm a common practice, even in the core libraries, is to use
type_. For example package.elm-lang.org/packages/elm/...There's ilk. I would generally start with a data model of the domain and 'group' often suggests itself as an entity name, and therefore as a foreign key (as in productGroup, userGroup etc), or community, department, set...
If the field/data item is there just for the purpose of logic or program design and does not refer to a defined entity or object, I would look again at why it is there.
Makes you want to program in PL/I, doesn't it? In PL/I the "keywordiness" is determined by the position of the word. That leads to fun things like
"kind" seems like a nice alternative but I must say that I end up either using a prefix like "orderType" or finding a way to not specify a type at all.
That might be an interesting second question: if you have to give something a type, what are differentiators? For instance a product might have a type: "paid" | "free" but you could also look at whether there is a price on it.
And in the other direction: when you add a type that implies a lot of difference, maybe you need separate entities.
genus/species/phylum :)
Most of the time if I'm doing document/table design for a data structure, I'll end up using something like
itemType, but after looking at this post and thinking on it a bit, some other seemingly good options would seem to be:purposelabeland perhaps,
mold.purposeI like in that it conveys the meaning of the thing, eg. "this thing is meant to be an array", where as label is a bit shorter to type, but could be confused for another more useful property on a data item.moldis nice because it is shorter to type, but a bit more ambiguous in terms of what it could be referencing./my2cents
My favorite alternative to "type" is "kind".