Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!ihnp4!houxm!mtuxo!mtune!mtunf!mtx5c!mtx5d!mtx5a!mat From: mat@mtx5a.UUCP (m.terribile) Newsgroups: net.lang.c Subject: Re: calculating leap years Message-ID: <1603@mtx5a.UUCP> Date: Fri, 10-Oct-86 14:36:04 EDT Article-I.D.: mtx5a.1603 Posted: Fri Oct 10 14:36:04 1986 Date-Received: Tue, 14-Oct-86 06:04:42 EDT References: <40@vianet.UUCP> Organization: AT&T Information Systems, Middletown, NJ 07748-4801. Lines: 41 > > 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) ,.. .,, ,,, ..,***_*.