Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write a bulletproof date validation routine.
#12
Meg,

Thanks for breaking down the explanation of your DinM logic. It's very clever, perhaps too clever since it takes more than 10 lines to explain it. I prefer the table-of-days-per-month approach, since it requires no explanation.

I have some similarly clever boolean logic on one line of code in one of my utility programs. It's been working for over 10 years, but every time I look at it, I vow to change it to something simple the next time I update it. This line of code is followed by about 8 lines of comments to explain it, and I myself still have trouble understanding it. I wonder who said KISS (Keep It Simple Stupid). There's a lot of truth in this.

Back when I was an assembly language programmer, we would go running to a colleague and say "look, I was able to code that logic in only 5 instructions". Normally, the less instructions, the more efficient it was. The thinking was: the shorter the program, the less bugs it should have. But, of course, you break the barrier of precise, efficient code when your code gets so clever that others can't figure it out --- not even yourself in time.

I'm glad you liked my leap year function. It also is on the borderline of being too clever. I'm sure you're aware that the leap year logic has been expanded for some time now to include an exception for years that are a multiple of 4000, similiar to the current logic for multiples of 400. I chose not to worry about it, so I limit my years up to 3999.
*****
Reply


Messages In This Thread
My entry - by Meg - 10-11-2004, 09:03 PM
updated - by Meg - 10-12-2004, 08:01 PM
Write a bulletproof date validation routine. - by Moneo - 10-18-2004, 05:16 AM
/nod - by Meg - 10-23-2004, 01:34 AM
Foo - by ToohTooh - 10-26-2004, 10:36 PM
Reply on Clarification Suggestion - by Neo - 10-26-2004, 11:37 PM
Re: Reply on Clarification Suggestion - by oracle - 10-27-2004, 02:00 AM
Hmm... - by ToohTooh - 10-27-2004, 02:12 PM
Re: Hmm... - by Neo - 10-27-2004, 10:12 PM
Thank you. - by ToohTooh - 11-01-2004, 04:54 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)