A pleasant walk through computing

Comment for me? Send an email. I might even update the post!

"Path" is ambiguous. Here are clear, consistent variable names.

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

References

One Sheet Summary: Tiny Habits

I make these to post on my wall and help me learn the subject. Be sure to read the book!


Download the PDF Version


Download the PDF Version

One Sheet Summary: Atomic Habits

I make these to post on my wall and help me learn the subject. Be sure to read the book!


Download the PDF Version

   Older