Search code examples
naming-conventionsvariable-names

Naming variables which represent json


I am naming a variable JsonArray versionsJA = jsonObject.get("versions").getAsJsonArray()
Is there any proper naming convention that can be done here? I mean something better than the name versionsJA?
Is it a good idea to include the type of variable in the name in some form?
Here the JA means JsonArray
Any alternate name that could be better?


Solution

  • Unless there are other version variables in your program, simply name it version. Encoding the type of a variable in its name is considered bad style since it adds unnecessary redundancy. In programming we want to keep each bit of information in only one place and in this case we can see in the declaration that it is a JSON array.