These words usually don't mean anything at all. Any variable could be called data. Any method could be called process. These words don't inform or dif

tmcw / naming.md Secret

submited by
Style Pass
2024-11-28 19:00:07

These words usually don't mean anything at all. Any variable could be called data. Any method could be called process. These words don't inform or differentiate. Most methods and variables that include these names are misnamed. Think hard and figure out what's better:

Let's say that you have a bunch of types describing database associations. Commentable, Archivable, etc. Strictly, dispositional adjectives. Follow this pattern for the rest of those types, even if there are awkward cases.

It's usually better to have awkward cases than to have exceptions to the rule. Observe XMLHttpRequest for example - a name that follows neither camelcase-without-acronyms (XmlHttpRequest) nor acronym-preserving camelcase (XMLHTTPRequest). Stick to one!

Needless abbreviations are a more subtle form of single-letter variable names. If something is a document, call it a document, not a doc. Only in extreme cases - referring to internationalization as i18n is any sort of shortening appropriate.

If you have a variable called rows and you pass it to a method that works with row data, the parameter to that method should probably be called rows as well. Unless there's a reason to use a different name for the same kind or instance of data, don't use different names for it, use the same name.

Leave a Comment
Related Posts