cancel
Showing results for 
Search instead for 
Did you mean: 

Why is there still software that can't tell the difference between 1 & many?

Community Veteran
Posts: 6,307
Thanks: 86
Fixes: 3
Registered: 08-01-2008

Why is there still software that can't tell the difference between 1 & many?

Got a 'MyCalendar Birthday Reminder' this morning.
Apparently I have '1 friends with birthdays today' .  I have more than one friend but only one who is celebrating his birthday today, and he has only one birthday today.
MyCalendar will be deleted as I can't stand this level of sloppiness.  It was bad enough when software reported things like '1 file(s) selected'.
Call me 'w23'
At any given moment in the universe many things happen. Coincidence is a matter of how close these events are in space, time and relationship.
Opinions expressed in forum posts are those of the poster, others may have different views.
2 REPLIES
kmilburn
Grafter
Posts: 902
Thanks: 2
Registered: 30-07-2007

Re: Why is there still software that can't tell the difference between 1 & many?

It largely comes down to how much effort the code writers want to apply to this sort of thing.
The quick and easy approach is the      
if ( numFriendsWithBirthday > 0 ) 
   print numFriendsWithBirthday + " friends with birthdays today"

verses the longer version
if ( numFriendsWithBirthday > 1 ) 
   print numFriendsWithBirthday + " friends with birthdays today"
else if ( numFriendsWithBirthday == 1 )  
   print numFriendsWithBirthday + " friend with a birthday today"

of for the adventurous
if ( numFriendsWithBirthday > 0 ) 
   print numFriendsWithBirthday + " friend" + (numFriendsWithBirthday == 1 ? "" : "s" ) +
           "with " + (numFriendsWithBirthday == 1 ? "a " : "" )+ "birthday" +
           (numFriendsWithBirthday == 1 ? "" : "s" )+ " today"

If you then want to support multiple languages, there's the question of how many strings you want translated and how complex you want things  to get,  usually resulting in a variation of the first example.
if ( numFriendsWithBirthday > 0 ) 
   print numFriendsWithBirthday + FriendsWithBirthdayString[ locale ]
Community Veteran
Posts: 4,917
Thanks: 338
Fixes: 16
Registered: 10-06-2010

Re: Why is there still software that can't tell the difference between 1 & many?

Or just use a translation system that can handle the plural forms, so it's like:

if ( numFriendsWithBirthday > 0 )
    print (translation (birthdayMessage, numFriendsWithBirthday))