"A", "an", and "the" in method and function names: What's your take?

Posted by Mike Spross on Programmers See other posts from Programmers or by Mike Spross
Published on 2010-09-16T04:56:54Z Indexed on 2011/02/09 23:34 UTC
Read the original article Hit count: 271

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?

© Programmers or respective owner

Related posts about style-guide

Related posts about naming-conventions