I have the following class
class X {
private List<Calendar> calendars;
// public int getCalendarCount()
// public int getCalendarSize()
// public int getSize()
// public int getCount()
// public int size()
// public int count()
}
I was wondering, what is the most common used naming convention, to retrieve the calendas’ size.
In List, they are using size.
However, in some 3rd parties library like XStream, they are using getXXXCount.
If
Xis only about holding a list of calendars, thensizewould make sense — but then that would beg the question of why you’re creating a class as opposed to just usingList<Calendar>.If
Xis going to hold much of anything else, then presumably it’s going to provide a means of accessing theListofCalendars, so it doesn’t really need a method to give that list’s size (sinceListalready has it). That would be the usual thing.But if you’re not directly exposing that
Listfor some reason (and remember, you can make it an unmodifiableList), then I’d probably go withgetCalendarCount.