- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
So here it goes
Admin
So here it goes
Admin
"tsirf".reverse.reverse.reverse
Admin
'FIRST'.reverse.chomp('http://'.reverse).reverse.reverse.chomp('https://'.reverse).reverse
Admin
that copy-paste code if I've ever seen any
Admin
I don't quite get the "basic calculus" of the first example: Whats wrong with simply, on below or above, setting the hour to the apropriate limit ?
Having said that, I do hope that whomever programmed that realizes that the "16" check means that the wishDate can go upto 16.59 (almost 5 o'clock).
Or, if rounding is implicitily applied, the result can range from 9.30 upto 16.29 ...
Admin
"usb".reverse.reverse.reverse
Admin
Code operating on Date objects that works? DON'T TOUCH IT.
(this comment was sponsored by java.util.Date)
Admin
That wouldn't work in in all languages that snippet could be (C# for example, because there DateTime objects are immutable).
Admin
You might want to reread the url of this page.
Admin
Any Brainf*ck programmer would know that even < and > operators are overrated.
Admin
Admin
Even in languages with immutable DateTime objects you don't need a loop to do that. You can easily replace that with:
For my own sanity I personally hope that every DateTime class in a modern language returns wishDate.Hour as an integer.Admin
It's "whoever". He programmed that, not him programmed that.
Captcha: wisi - I'm acting wisi right now.
Admin
Not surprised...every "alternate" data solution is WRONG....
Admin
OK, I see the problem! You don't need the ifs, because the while loops themselves test at each iteration!
Admin
What I was referring to is that although the code seems to say no moment over 4 o'clock in the afternoon may be picked, the wishDate.Minutes field will allow you to go way beyond it. Assuming ofcourse that the"wishDate" granularity is lower than hours.
Maybe, just for readability, writing ">= 17" would have been a better choice.
Admin
Seems as if DateTime APIs really are a big problem...
Admin
The "reverse.chomp" way of string manipulation is really ingenious (after all, chaining function calls is recommended practice for a variety of languages), although it lacks a bit in readability.
But, sadly enough, a chance to use a regex has been wasted.
Admin
Mind you, that was the comparision, not the assignment.
Admin
That depends on how much of a caveman you are. Him smart. Him program that.
Admin
Admin
Did anyone else start hearing the "Cha Cha Slide" reading all the .reverses?
Admin
Now that's much safer.
Admin
Assuming integral .Hour function:
Admin
Admin
The string manipulation code would look better in APL.
Admin
Admin
Admin
In human language that ">=" means "larger or equal". When the result is or comes down to 17 the comparision still returns true, and another hour is subtracted.
Nope. Als long as you want to keep the origional code, both.Also, Rule: Never ever use two differently-written comparisions when you mean them to be the same. Especially not in a situation as in the origional code.
Admin
Admin
or simply:
Then we just select the appropriate value:
Admin
Admin
Congratulations! You just explained the whole joke without even realizing it.
Admin
That's really bad formatting. It should be:
Admin
On second thought, magic numbers are bad too. It should be:
[/quote]
Admin
Remy, please repeat this 100 times:
Admin
Admin
nuns.reverse.reverse
Admin
[quote user="Brendan"]On second thought, magic numbers are bad too. It should be:
[/quote][/quote]
Actually I'm not happy about all that access of wishDate.Hour:
I used z because then its easier to migrate to in case we need to implement Hour as a complex number.
Admin
// has to be a negative value if (discountTotal > 0) { discountTotal = -1;
}
See, now it's a negative value, as per spec. No arithmetic needed!
Admin
Admin
But that creates, to me, a problem: How can an object be considered immutable when you can change its outward appearance using the objects own methods ?
Or, to put it differently: Why should such a date object be allowed to be changed using an addition method, but not by using a setter method. Whats the logic behind it ?
Admin
I like where you're going; but I think we've forgotten rule #3 (never write the same code twice). For this reason I'd do a "#define y z = (z" and then a "#define x z);" to get this:
Admin
Admin
Time and Date again, we all see that days are hard. For some reason people won't use the logical solution of seconds since Midnight January 1, 1970 Pacific Daylight Time as a sensible standard.
Because dates and thyme are so hard, so the solution must be equally hard. It takes a well seasoned developer like myself to craft around all of the corner and edge cases that appear. The proper solution to today's problem is:
Admin
If you look at the code closely you see that the return value of the AddHours method is assigned back to the original variable. That's because the method doesn't change the actual object, it creates a new one instead and returns it.
Admin
Admin
One of the tricks I taught my dog in doggie training is "reverse" You say "Reverse, reverse, reverse, reverse," and each time the dog takes a step backwards you throw him a treat.
Admin