6

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?

Edit

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.

Community
  • 1
  • 1
Jai
  • 8,165
  • 2
  • 21
  • 52
  • You are returning with a collection. Is that not something obvious? – KarelG Mar 16 '18 at 07:41
  • @StephenC Yes, I am aware I will hold the final say how things are going to be. But I just want to see if anyone has ever struggled through this and had came up with a choice, with a reason backing that decision. Using camelcase for acronym is also something I find more logical after reading many opinions from other SO questions. – Jai Mar 16 '18 at 07:51

2 Answers2

10

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 acronym DVDS, 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.)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • This can be placed as a comment. – KarelG Mar 16 '18 at 07:41
  • 8
    @KarelG: Answers don't go in comments, they go in answers. That's the SO model. It's not an unreasonable question, particularly for a non-native English speaker. – T.J. Crowder Mar 16 '18 at 07:42
  • It does not fit the SO scope. But I won't do a cv or any downvotes because the OP is fairly new here. So I forgive it to him. You should know that. – KarelG Mar 16 '18 at 07:43
  • I think I found something convincing here. That `dvdss` part sounds logical. – Jai Mar 16 '18 at 07:56
  • @PrzemysławMoskal: I think that would stray too far into opinion-land, and unfortunately, the JDK has used both. :-) (Personally, I prefer keeping the acronym in all caps perhaps with the exception of "Id" -- but I fear I may increasingly be in the minority on that.) – T.J. Crowder Mar 16 '18 at 07:57
  • @T.J.Crowder Could you elaborate on more correct way: 1) `findAllDvds()` or 2) `findAllDVDs()` when singular is DVD? I found that acronyms are being written in both ways (all letters of acronym uppercase or only the first letter of acronym uppercase, the rest lowercase) and I'm not sure which one is considered as the better choice. Sorry for deleting comment (I thought that you edited answer after my comment and that's all), I have put it again here to let others know what I was asking for. – Przemysław Moskal Mar 16 '18 at 08:03
  • @T.J.Crowder Thank you for giving me these explanation. Personally I prefer DVDs over Dvds, too. It's a bit of surprise for me when you say it's not that common to uppercase whole acronym, seems like a more correct choice to me anyway. Thanks! – Przemysław Moskal Mar 16 '18 at 08:06
2

This is a really opinion based question and could be closed.

However, this should be the correct version:

public List<Disc> findAllDvds(DiscHolder holder) {}
sarkasronie
  • 335
  • 1
  • 2
  • 15