Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/C++: Naming conventions for arrays? [closed]

What is a good naming convention for arrays? I am working on a code base with few thousand line of codes and there is no consistent naming convention for arrays. Few ppl name them by appending List at the end of the name like *message_list*, which I really dont like as it wrongly suggests that this is a list(linked list), and few people name them by appending 's' at the end like messages which is better than previous approach but sometimes fails.

I want to know if there are any naming conventions out there for array type variables?

like image 809
binW Avatar asked May 24 '11 14:05

binW


1 Answers

Name them for what they hold. An array of messages should be called messages. An array of file names should be called filenames. Capitalize to suit your whims and prejudices.

There are those who argue for the singular, suggesting that message[i] is singular and better than messages[i]. There is some justice in that, but the counter-argument is that the variable names an aggregate, so the plural is better.

I'd not use a suffix such as _list for an array.

like image 162
Jonathan Leffler Avatar answered Sep 22 '22 10:09

Jonathan Leffler