Joe Lapp
Joe Lapp

Reputation: 2965

Naming conventions for JSON-serializable variables

What naming conventions are people using for variables that hold JSON-serializable objects? We'd like the name of the variable to remind us to only store information in the object that can be serialized into JSON without losing information. Applications include HTTP sessions, non-searchable database columns, data logging, and serializing restorable application state.

The obvious contenders, at least from the perspective of someone programming in Javascript for node.js, seem to fall short:

The best I can do is prefixJSONInfo, prefixJSONData, or prefixJSONObject, but I was hoping for something more succinct and readable. The prefix may be lengthy and descriptive too.

This question mainly applies to programming languages that support variant-type variables, such as Javascript. These variables are meant to hold a mishmash, but the programmer needs to be reminded to limit the types of values that are thrown into the mishmash.

Upvotes: 0

Views: 1124

Answers (1)

ryancdotnet
ryancdotnet

Reputation: 2270

In this case, it seems that a specific acronym might serve a good purpose.

JSONSerializable

written:

JSS or Jss

Examples:

prefixJss

customerDataJss

sessionInfoJss

Or maybe even:

JSONSerializableObject

prefixJSO

prefixJso

My $0.02. This might be more opinion based, as I don't think there are any globally accepted standards for these things. There are best practices, such as you mentioned (like short but descriptive). It's up to the developer or team to determine which short and descriptive versions they like (team preference).

Trust me tho, I understand how difficult naming things is sometimes. :)

Upvotes: 2

Related Questions