"A", "an", and "the" in method and function names: What's your take?
- by Mike Spross
I'm sure many of us have seen method names like this at one point or another:
UploadTheFileToTheServerPlease
CreateATemporaryFile
WriteTheRecordToTheDatabase
ResetTheSystemClock
That is, method names that are also grammatically-correct English sentences, and include extra words purely to make them read like prose. Personally, I'm not a huge fan of such "literal" method names, and prefer to be succint, while still being as clear as possible. To me, words like "a", "an", and "the" just look plain awkward in method names, and it makes method names needlessly long without really adding anything useful. I would prefer the following method names for the previous examples:
UploadFileToServer
CreateTemporaryFile
WriteOutRecord
ResetSystemClock
In my experience, this is far more common than the other approach of writing out the lengthier names, but I have seen both styles and was curious to see what other people's thoughts were on these two approaches.
So, are you in the "method names that read like prose" camp or the "method names that say what I mean but read out loud like a bad foreign-language-to-English translation" camp?