views:

139

answers:

5

This is a language-agnostic question - unless you count English as a language.

I've got this list of items which can have very long names.

For aesthetic purposes, these names must be made shorter in some cases, adding dots (...) to indicate that the name is longer. So for example, if article.name returns this:

lorem ipsum dolor sit amet

I'd like to get this other output.

lorem ipsum dolor ...

I can program this quite easily. My question is: how should I call that shortening operation? I mean the name, not the implementation. Is there a standard English name for it?

+6  A: 

Truncation, or soft truncation (because of the ellipsis)

I would call the function truncate, and that seems to be the consensus.

CPAN: http://search.cpan.org/~rjbs/String-Truncate-1.100570/lib/String/Truncate.pm
MooTools: https://mootools.lighthouseapp.com/projects/2706/tickets/670-new-addition-stringtruncate-method
Prototype: http://www.prototypejs.org/api/string/truncate
Smarty: http://www.smarty.net/manual/en/language.modifier.truncate.php

Infinity
I received lots of very valid responses. I'm choosing this one because it happens to be called like that on the library I'm using (rails). This comment helped me find it. I also like it a bit more than ellipsize, although I realize it is a completely personal choice.
egarcia
+2  A: 

truncate: To shorten something as if by cutting off part of it.

Source

ChaosPandion
+11  A: 

UserlandFrontier calls such a method ellipsize:

http://docserver.userland.com/string/ellipsize

So does Android:

http://developer.android.com/reference/android/text/TextUtils.html

and many others (see google)

seanizer
The name ellipsize seems a bit obscure to me. Pretty much everyone will know what truncate means
ChaosPandion
I agree that everybody knows what truncate is, but I think that is exactly the problem: truncate implies that the string is cut of and not that it is shortened and an ellipsis added.
seanizer
I like ellipsize, and hope that it catches on as a "standard" name for this function. Truncate is a bit generic.
I. J. Kennedy
To me it implies the addition of an ellipsis. Maybe a hybrid is in order?
ChaosPandion
Actually after a bit of reading it makes perfect sense.
ChaosPandion
You know, they say you shouldn't verbalize nouns ;->
Thomas
@Thomas - Maybe if the English language made sense maybe more people would follow the rules. :)
ChaosPandion
Thanks a lot for your responses. I prefer truncate however. "ellipsize", while appropiate, is not real English, but "English-ish". Nothing wrong with that, but not exactly what I was looking for. But +1 because if I see ellipsize in the future I will probably know what it means.
egarcia
+7  A: 

I'm not a huge fan of creating new words for function names. I'd be inclined to use actual words and call the function TruncateWithEllipsis or something abundantly clear.

Thomas
Same here, something like `'lorem impsum dolor'.truncateWith('...')` sounds good to me
Infinity
@Infinity - That would go perfect with a c# extension method. Of course it might be annoying to have to specify every time.
ChaosPandion
This was a bit too long for my taste, but your code will probably be more readable than mine for stranger eyes. +1 for that.
egarcia
+1  A: 

Although less explicit than Thomas' TruncateWithEllipsis, I might name it abbreviate because I may want to abbreviate things differently in the future, or depending on context, or what the thing I'm abbreviating is.

Stephen P
yes, sounds very good
seanizer
Thanks for your feedback. However, I'm not planning to change this functionality in the future, so the truncate name sounds a bit more appropiate.
egarcia
IMO, abbreviate would mean transforming "In My Opinion" to "IMO"
Don
@Don, "abbr" is the most common abbreviation for "abbreviation". An initialism is, indeed, *one form* of abbreviation; truncation is another form of abbreviation.
Stephen P