Where to start counting, 0 or 1?
My hypothesis:
It's more usual to start with 0 when counting steps and with 1 when counting things.
Maybe that's why programmers start with 0, they usually count steps. Age also starts at 0, nobody is born being 1 year old, although we are living our 1st year of life. Races also start at 0. When you want to know how many eggs are in the basket it makes little sense to say, oh i have an empty basket, 0 eggs, let's add some, now i have 1 egg, 2 eggs, etc.
8 comments
[ 4286 ms ] story [ 243 ms ] thread0 means nothing in any situation
Honestly, it depends on the situation, and I think you got it right. Things start at 1, steps start at 0.
But starting at 0 presents a problem. If I have a set of stairs with 5 steps, I either count the ground or the landing in my steps but never both. If I want to get to the middle (3rd) step, if I'm at the bottom I just count 1, 2, 3 steps and I'm there, but if I'm at the top I only count 2 steps down. There are really 6 positions I could be, but only 5 steps. You guys may have this down, but it still trips me up sometimes.
For children's growth status tracking, the UN has a method in computing for children's age and have been localized. I have used the Philippine reference and age is computed in months. There is a 0 month age.
Culturally, I would presume you might be referring to parts of the Philippines where people start counting age at one. I have never heard of this. We celebrate the first birthday the usual way: one year after birth.
Except that, by convention, in China what you consider zero is already "0 years 9 months".
Its similar to describing the epoch time to my colleagues. You know, epoch time: the number of seconds which have passed since midnight (GMT) on January 1st of the 45th year of the Showa era.
Incidentally, you want to have some fun in outsourcing? Try convincing your Indian outsourcing team that it is Very Bloody Important that their code account for the edge case when the last day of one era and the first day of another era fall on the same day of the Western calendar. ("The data are passed in as strings, the strings are always in the same format, why can't we use string compare? It saves the conversion into a date." "That is premature optimization and will introduce a bug for the following dates:..." "There's only a few of them!")
Edge cases, I would estimate, would account for 30% of a program's logic. When doing the first cut, I classify those as exceptions: abnormal values that generate, well, exceptions.
Time-bound edge cases are abundant, especially in financial apps. End of periods, beginning balances, ending balances.
Other edge-case values are max and minimum values, limits of whatever sort. And these don't include limits of systems, like how many times a stored procedure can be dropped and recreated, that are not commonly known or just ignored hoping the app will hold before the longint limit will be reached.
Do what makes sense according to the problem you're solving.
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...