I know there had already been similar discussions on such naming conventions. However, I'm having problem with plural acronyms.
public List<Disc> findAllDvds(DiscHolder holder) {}
public List<Disc> findAllDvd(DiscHolder holder) {}
Assuming that I have decided to use CamelCase for acronyms, which of the two is generally more acceptable?
I am aware this will invite opinion-based answers, but sometimes when you are in doubt, you just need people to give advises and feedbacks.
To add on, the confusing part here is that findAllDvds
can imply a new acronym DVDS
, and it can be considered confusing.
Some guidelines Microsoft has written about camelCase are: When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton . However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io .
Java uses CamelCase as a practice for writing names of methods, variables, classes, packages, and constants.
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
The . NET Framework guidelines recommend that acronyms three letters or longer use mixed case for PascalCase and camelCase identifiers, except for the first word of a camelCase identifier. Thus for a class name you might have XmlDocument , while a local variable might be named httpRequest .
The first (findAllDvds
). The second (findAllDvd
) is simply incorrect, "all" implies more than one, but "Dvd" is singular in English.
Re your edit:
the confusing part here is that
findAllDvds
can imply a new acronymDVDS
, and it can be considered confusing
Since the "all" implies multiple, the "s" on "Dvds" reads as a plural, not part of the acronym. If it really were DVDS, the name would be findAllDvdss
or similar.
It's said that in computer science, there are three hard problems: Cache invalidation, and naming things. (Off-by-one errors are just common, not hard.)
This is a really opinion based question and could be closed.
However, this should be the correct version:
public List<Disc> findAllDvds(DiscHolder holder) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With