calculating leap years

m.terribile mat at mtx5a.UUCP
Sat Oct 11 04:36:04 AEST 1986


> > It is particularly galling to see a correct algorithm criticized as
> > overkill when it is as simple and short as the above code segment.  There
> > may be a justification for writing code that only works part of the time if
> > the fix is costly and difficult.  However, it should be a general rule that
> > an algorithm which works in all cases is preferred over one that only works
> > in most cases.
> > Instead of panning someone's code because he has written it more correctly,
> > one should adopt the improved algorithm with gratitude.
> 
>   You are missing the point: I wrote that doing the simple check for
> divisibility by four is sufficient for most programs.  I would bet that
> 99% of programs don't need to handle dates with precision outside of
> +/-20 years from the current date.  Geneology programs might want more.
> Astronomical programs almost certainly do.  In the same sense, not all
> arithmetic calculations need be done in double precision.

``There is never time to do it right, but there is always time to do it
over.''  If you always try to get away with the stuff that you can probably
get away with, you *will* get burnt.  More important:  innocent users will
get burnt.  People who never met you, people who trusted the stuff that
``always worked'' will get burnt needlessly.

There are always engineering tradeoffs, but when it's cheap to be safe,
fer pete's sake, be safe.

Three is mounting concern in the commercial (read COBOL) world right now
because old code with old date handling is begining to break.  Nobody
expected the old code to be running for 20+ years; nobody expected that
people would take old code segments that they couldn't make sense of and
re-use them blindly, but people did because managers said ``use what's
already working.  Evolve, rather than destroy''

Meet my pet, Peeve ...
-- 

	from Mole End			Mark Terribile
		(scrape .. dig )	mtx5b!mat
					(Please mail to mtx5b!mat, NOT mtx5a!
						mat, or to mtx5a!mtx5b!mat)
					(mtx5b!mole-end!mat will also reach me)
    ,..      .,,       ,,,   ..,***_*.



More information about the Comp.lang.c mailing list