Include Data Formats in Variable Names [VF2]

Include Data Formats in Variable Names [VF2]

Tip VF2

“Data formats” are a closely related cousin of “units.” Programmers often need to know data formats to be able to work with data, so it’s beneficial to include data formats directly in variable names.

Data formats can often come into play when dealing with data stored in strings. Programmers have created all kinds of textual data that can be stored in strings - CSV, JSON, XML (to name a few). It can be beneficial to embed data formats in variable names similarly to units. If a programmer is given a variable that just appears to be of a generic “string” type, he/she at least needs to know the format of the data stored in that string to be able to work with it. And embedding data formats in these kinds of variable names can also help expose obvious errors:

ParseJson(records_in_csv);

Examples:

Related content