Distinguish Between Different Levels of Filesystem Abstractions [VD13]
Tip VD13
Avoid being too abstract if multiple filesystem entities come into play in a codebase (almost certainly the case for any non-trivial codebase). Make sure names sufficiently distinguish between filesystem entities at different levels of abstraction.
For example, one could argue that a variable name like file could be a higher-level abstraction more familiar to users than something like a filepath or file_contents. But code like this can be ambiguous:
ReadFile(file);Is file some kind of “object,” “filepath,” or something else?
It’s very easy for at least 3 different concepts - a file “object,” filepath, and a file’s contents - to come into play within the same body of code. When that happens (and it often will), overly abstract names can be problematic. Reserve names like file, folder, or directory for higher-level “objects,” rather than lower-level concepts. The following code example illustrates how different levels of abstraction can be distinguished within the same code: