Format and Parse Naming Convention


Here are some conventions I love for naming string de/serialization functions.

The names

The names are parse and format. Prefixes, as in: parseAThing or formatAThing.

I love these names. There are many std libs that use these names for things like dates and strings.

When to use

When a string is being created from a different format (eg, from number, object, etc into a string), I use format. This is serialization.

When something is being read from a string into a different format (eg, from string to number, object, etc), I use parse. This is deserialization.

I used to over-use this convention. It was confusing to other programmers, so I have replaced many of my uses with map.