"Path" is ambiguous. Here are clear, consistent variable names.
2020-10-26 10:30
Quiz du jour
public void ImportRecords(string path) {}
public void ImportRecords(string file) {}
public void ImportRecords(string folder) {}
What's the argument for each of the parameters above? Does "path" include a filename? Do "file" and "folder" include a path?
File system input/output is just about as old as computing itself, and yet I'll bet you see--and use!--ambiguous I/O variables all the time.
Clear, Consistent
Here are four variable names I've settled on to keep the meanings clear. They take just a little more effort at first, and with practice become a habit.
Variable | Means | Example |
---|---|---|
fileName |
just the file name | customers.csv |
filePath |
full path to file | c:\transfer\import\customers.csv |
folderName |
just the folder name | import |
folderPath |
full path to the folder | c:\transfer\import |