- 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
Discourse is a type of insanity: [image]
Admin
You're just not privy to the whispers on this thread.
Admin
nah. unlisting the thread for rasins counts as a post.
because discourse
Admin
But what about the second reply that @LB_ had a notification for? Whispers, man! Whispers!
Also, I think you may have whooshed.
Edit :fa_flag_checkered:
Admin
26 posts were split to a new topic: Whooshing in an article
Admin
I don't know much Python; is that last one supposed to be:
Admin
Only if you assume that everyone's birthday is the first of January…
Admin
or if are okay with overestimating the age of people by a maximum of one year and an average of six months
Admin
And this is again why you don't roll your own date logic. TRWTF is the article gets this backwards.
All centennial years are divisible by 4 (100 % 4 = 0), author was looking for 400 as the exemption where you have a regular leap year on a centennial, as 2000 was a leap year, but 1900 and 2100 will not be.
http://www.timeanddate.com/date/leapyear.html
Admin
The student ID one looks like a roundabout way to strip leading zeroes. I've seen similar things done.
Admin
Don't do that. It's not a number; it's an identifier. It's an arbitrary sequence of characters (all of which happen to be digits). You're not going to be doing arithmetic on it. Leave it as a string.
If you want to accept input without the leading zeroes, fine; left-pad it with
'0'
characters. If you want to display it without the leading zeroes (why?), substring is more efficient than string->int->string.Just like ZIP codes, phone numbers, etc.: They're not numbers; don't use numeric types for them.
Admin
Um.... UM!! UMMMMMMMMMMMMMMMMMMMMMM!!!!!!!!!!!!!!!
WHY?! WHY?!?!?! WHY WHY WHY?!?!?!?!eleventyone
*Calms down
Someone please tell me there is a tiny bit of logic in this statement. Please!
Admin
I wish I could but... well, I wish I could, that's all.
Admin
If you want logical statements, why are you reading TDWTF?
Admin
Why? Some programmer somewhere is a fucking idiot.
News at eleven.
(At least the compiler will be able to throw that crap out and issue simple code out the back end.)
Admin
FTFY.
Admin
Oh come on, it's perfectly obvious. What about those situations where null isn't really null, it's just pretending to be null in order to try and fool the door staff? This implementation is precisely how you get around this sort of stuff that nulls try to pull when you're not on your guard. "Sorry, but if you tell me you're null but in fact you're not null, then I'm just going to have to treat you as null and if you're actually not null, you will be after I've finished with you, sunshine. That'll learn yer ..."
Admin
That code is just to handle the case of typed nulls.
But in this case - if the null of type AClass is not identical to the null of class object -, that statement will try to assign a value of type object (which happens to be null) to a property of type AClass, which is bound to fail. Not just throw an exception, but at compile time. (Unless the property is of type object. Why not, everything being of type object saves a lot of trouble with type mismatch errors.)
Admin
I've been seeing a lot of code lately from developers who mostly work with weak-typed languages, trying to use a strongly-typed language. They have this general mistrust of numbers of any sort, and will only use string variables everywhere. Lots of casts from strings to ints or doubles and back.
The worst I've seen is people doing this while buffering output for an RNG. They end up with zeroes stripped out of sequences of numbers which does wonders for the supposedly random distribution, or strings that are accidentally null-terminated early (direct cast of bytes to characters).
I just want to reassure them and tell them it's OK, the bad languages can't hurt them here. You are in control, you can decide how numbers will be represented, and you can trust them to never change. Unless they fuck something else up spectacularly.