2

It is more an English question than a Coding question, but both are related :

Should we put an S in the name of array of things ? I want to know if it is just an opinion question or if there is a real English rule.

How to name an array of that array ?


Example 1

I have an object named Constraint. I want to create an array of that object. How should I name it ? ConstraintsArray or ConstraintArray ?

Answer

Do not use Hungarian Notation. Call it Constraints.


Example 2

How to name an array of that array ?


Thank you for your answers.

Samuel
  • 135
  • 1
  • 13

4 Answers4

2

IMO, you should just call it "constraints", without the "array" prefix (referring the Clean code.. :) )

user
  • 3,058
  • 23
  • 45
  • 2
    Yes. Adding an `Array` suffix is one step away from poorly done [Hungarian Notation](http://stackoverflow.com/questions/111933/why-shouldnt-i-use-hungarian-notation), with all the issues that can cause. – Phylogenesis Jun 26 '15 at 08:30
  • Thank you, you opened my mind with the Apps Hungarian vs. Hungarian Notation. I will clean my code. – Samuel Jun 26 '15 at 09:59
  • 1
    @Samuel To be clear, I'm not a particular fan of Hungarian notation in any form (IMO you should use separate classes to describe behaviour such as SafeHTMLString given in one of Joel's examples and then the compiler itself can protect you from misuse), but using it to just describe the type of a variable is a much more egregious problem that just leads to issues when the type is changed, but not the name. – Phylogenesis Jun 26 '15 at 10:39
1

ConstraintsArray seems redundant in meaning.

You can use ConstraintArray or just Constraints.

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
0

I think it really depends on the coder himself. No real rules on variable on Grammar. :) . for me I like using singular form eg. ConstraintArray...

grit
  • 83
  • 4
0

That is very much up to your personal style. I would not do it. A personArray is already a list of more than one person. You should know that.

But if the array objects are lists too it's a very different situation. Names like itemsDictionariesList, or repositoriesArray is something I used in my project.

TalkingCode
  • 13,407
  • 27
  • 102
  • 147