Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good way to make a type a plural when writing comments?

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?

like image 978
Joey Adams Avatar asked Aug 10 '10 05:08

Joey Adams


2 Answers

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

like image 112
Jake Petroules Avatar answered Nov 13 '22 05:11

Jake Petroules


I would use the 's' in parentheses.

/* Get a list of Thing(s) from somewhere */
like image 42
Ido Weinstein Avatar answered Nov 13 '22 03:11

Ido Weinstein