views:

46

answers:

2

When writing comments, I sometimes find myself needing to talk about a type (class, struct, etc.) in plural when writing comments, such as:

/*
 * getThings
 *    Get a list of --> Things <-- from somewhere.
 */
Thing *getThings(void);

The problem is, the type name is singular (namely, Thing), but I want to talk about them in plural in comments.

If I say Things, it suggests to the reader it's talking about a type called Things, which is not the case. If I say Thing's, it looks awkward because it's not grammatically correct (it's either possessive or "Thing is", not plural). I could talk around the problem and say a list of Thing items

What's a good convention to stick to when writing plurals of types?

+2  A: 

Well, depending on the documentation system you're using, you can wrap the name of the type in a special syntax and put the s outside it. For example:

.NET XML comments

Get a list of <see cref="Thing"/>s from somewhere.

doxygen C/C++ comments

Get a list of \link Thing \endlink s from somewhere.

Not 100% certain on the doxygen variant but it should be something like that.

And if you're not using a particular documentation system and thus have no special comments, I'd do something like:

Get a list of [Thing]s from somewhere.

Or you could use ( ) or { }, depending on preference...

Jake Petroules
Good thought. On StackOverflow, I take advantage of code highlighting by saying `\`Thing\`s`
Joey Adams
Hey, you could even use that syntax outside of SO in absence of a documentation system with special comments. Interesting thought...
Jake Petroules
+1  A: 

I would use the 's' in parentheses.

/* Get a list of Thing(s) from somewhere */
Ido
I thought about that, too. However, on second thought, I think it would be annoying to read after a while, similar to [Yoda conditions](http://stackoverflow.com/questions/2349378/new-programming-jargon-you-coined/2430307#2430307) like `if (5 == count)` or saying "she or he" in English. Those are the types of things that cause me to take my mind off of the subject matter and hate the author for insisting on backwards thinking when it really doesn't help anything. Nonetheless, +1. It's kind of hard to answer my question without going down that road, anyway.
Joey Adams
I agree, it would be annoying to read after a while same as the Yoda conditions (I like that phrase) but than every unnatural variation from natural language would.
Ido