DEV Community

What are some alternatives to the word "type"?

Ben Halpern on November 13, 2018

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.

Collapse
 
hinzster profile image
flinkflonk

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

IF IF = THEN THEN THEN = ELSE ELSE ELSE = IF
Collapse
 
nathanbland profile image
Nathan Bland

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:

purpose

label

and perhaps, mold.

purpose I 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.

mold is nice because it is shorter to type, but a bit more ambiguous in terms of what it could be referencing.

/my2cents

Collapse
 
andy profile image
Andy Zhao (he/him)

Personally want to see flavor in our database, but that's just me 🙃

Collapse
 
deciduously profile image
Ben Lovy • Edited

kind has a very specific meaning too - while not a reserved keyword anywhere as far as I know, it could potentially be confusing when used to mean something else. I lean towards group or _grp as a suffix.

Collapse
 
goyo profile image
Grzegorz Ziemonski

Haha, this reminds me of an educational app that I once written in which the teacher was meant to organize "classes". I was torn between Java-ish "clazz" spelling and less domain-ish "lesson" (I went for the "lesson").

Anyway, for issues like that Thesaurus is my best friend. I don't think there's a one-size-fits-all synonym for type, because different synonyms fit best in different contexts.

Personally, I always look for a synonym rather than prefixing like post_type or widget_type, because I hate the way it reads in the code later e.g. widget.widget_type, grr!

Collapse
 
gene profile image
Gene

I don't think there's any other word that can be used as an alternative to type which also gives the correct impression to the person reading it that you are exactly referring to a type of something...

Collapse
 
dopitz profile image
Daniel O.

type is 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_id or customers.customer_privacy_type_id.

Collapse
 
phallstrom profile image
Philip Hallstrom

Not an answer, but where are you seeing type as 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 type just means "type of class." If we're talking about something else then other words are useful, but generically.. oof.. tough to say.

Collapse
 
quii profile image
Chris James

typ

Collapse
 
avalander profile image
Avalander

That one works great in Swedish.

Collapse
 
quii profile image
Chris James

TIL!

Collapse
 
griffinsauce profile image
Joris Griffioen

"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.

Collapse
 
mark_nicol profile image
Mark Nicol

Depends so much on context. Names are tough. Is it helpful to think about what the type is distinguishing between? Sometimes, for me,the 'why do I have this field?' suggests an answer (user_type -> access_level)

Collapse
 
ourmikegeorge profile image
Mike George

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.

Collapse
 
cjbrooks12 profile image
Casey Brooks

I will sometimes use kind in these situations but usually end up prefixing type with something more semantic: user_type, post_type, etc.

Collapse
 
wking profile image
William King

In Elm a common practice, even in the core libraries, is to use type_. For example package.elm-lang.org/packages/elm/...

Collapse
 
david_j_eddy profile image
David J Eddy • Edited
Collapse
 
ben profile image
Ben Halpern

breed

Collapse
 
avalander profile image
Avalander

lot is the best alternative I've seen so far :D

Collapse
 
jheijmans profile image
Jeroen Heijmans • Edited

I usually suffix _type depending on what I'm categorising (e.g. widget_type). "Sort" also is nice and short, but has the downside of being a form of the verb sorting.

Collapse
 
buinauskas profile image
Evaldas Buinauskas

True. I normally would think sort as order of something.

Collapse
 
ben profile image
Ben Halpern

Cool! I’ve used kind and group at times. Kind strikes me as a pretty solid synonym for type, and group is a great word for type-like things.

Still in search of the perfect synonym 😂

Collapse
 
chiangs profile image
Stephen Chiang

I like group, which can easily be inferred from shorthand grp to save typing...

Collapse
 
awwsmm profile image
Andrew (he/him)

genre

Used in French to mean "kind of" / class / type.

Collapse
 
reg__ profile image
Adam Sawicki

My favorite alternative to "type" is "kind".

Collapse
 
gsto profile image
Glenn Stovall

genus/species/phylum :)