Distinguish Between “Names” and “Paths” Where Applicable [VD14]

Distinguish Between “Names” and “Paths” Where Applicable [VD14]

Tip VD14

Programmers often need to know if a string they’re given is just the “name” of a file within a folder/directory or a longer path. A “path” can often be used “as-is,” but with just a filename, it often has to be looked-up to get a longer path. Use name and path suffixes to help differentiate between the different kinds of data.

A filename is a subset of a filepath, so if both are acceptable for a variable, you can use a path suffix and document the considerations.

The following examples of function signatures demonstrate the distinctions:

 

Related content