- 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
Wake up @PaulaBean!
http://thedailywtf.com/articles/accurate-comments
Paging @mark_bowytz, @apapadimoulis
Admin
We are looking into the Paula Bean issue. We just need someone more brillant.
Admin
Maybe @PaulaBean is trying to do a string padding on the article title?
Admin
Is there a limit on spaces?!?!
Admin
Apparently not...
[image]Perhaps they need to be rate limited...
Admin
About that final note:
Didn't you mean
it's
?Filed under: Spellar'd that for you
Admin
FTFY
Filed under: or would that more correctly be "anti-@accalia'd"...?
Admin
un-@accalia'd?
Admin
that works too.
:laughing:
Admin
Picks up the phone, calls the IT help desk: "Hello, I need a new keyboard. This one has run out of spaces."
Admin
Well... that's one way to ensure none of them are wrong...
Admin
Those who cannot remember
printf
are condemned to reimplement it... poorly.Edit: I actually meant printf and its variants, so if this were C it'd be sprintf. Since this looks like Java, it'd be
String.format
.Admin
Maybe I am missing the point but why would this result in a null pointer exception? My C is very rusty since I found Python.
Admin
It's not C.
It would result in a null pointer exception if
registrationNumber
were null.Admin
I've seen these type of comments before, I don't get it. Why add a stupid "This isn't really good" comment instead of you know actually refactoring the damn code to be improved.
Admin
If you've never been in a situation where a boss was afraid to touch anything and had developed an instinctive flight reaction against the word "refactor", consider yourself lucky. "It's a 5 minute fix, chief" "I don't care. QA says it'll take them 3 days to test it" "Um, shouldn't they just have to enter a couple strings?" "Probably, but I'm not going to tell them how to do their jobs" "Apparently they're telling us how to do ours...."
Admin
FIXED
Admin
:laughing: "You keep using that word. I do not think it means what you think it means."
Admin
I assume that this is a joke. At least, I hope so.
The thing that interests me about string padding is that it is an extremely simple problem to state, and there are many solutions, but there is no obviously optimal solution. (Feel free to prove me wrong).
Admin
There are several obviously-better-than-this solutions though.
Admin
That's generally because QA doesn't know what goes into programming. Nor do they have a full understanding of how a fix changes the system or affects surrounding code. The developer should be able to help QA understand that and that the test shouldn't take too long.
Of course, that would be in a sane, communicative environment.
Admin
Oh, no, no, no... This is a perfect chance to use a for loop! :anguished:
Admin
The number of times I've had a programmer tell me "But I didn't touch that part, why did it break!???!?!?" indicates to me that that sword cuts both ways
Admin
ITYM recursion
Admin
Also, I know what you meant, but STFU :angry: The assumption that nobody in QA understands code is part of why many in QA never bother to learn code and why many coders utterly disregard QA
Admin
9/10, needs more factories.
Admin
This one pretty much does the job, with some variation based on how you're storing your strings:
That's guaranteed to be O(targetLength).
Admin
That'll do horrible stuff if
length(original) > targetLength
Admin
FTFY
Admin
Admin
If a function gives a null pointer exception when you pass a null input, then don't do that.
So in all "1,234" places where this function is called, all team members are required to do this:
Fixed.
Admin
What's that?
Admin
What about this strategy?
(It's a bit easier in languages that have a "right" function.)
Edit: Still fails for null. Fixed.
Admin
+1 Funny
Filed under: inb4 slashdot is leaking again
Admin
I don't think so
Admin
Well, yes, especially all the ones that start with a test for null and behave appropriately.
The problem is to find one that is the most efficient in resources. I have in the past had the problem of reconstructing a space padded fixed field text file from a database for legacy reasons. When you are constructing a file that will exceed 100Mbytes and has, say, ten space padded fields, the efficiency of the padding algorithm makes an awful lot of difference to execution time.
Don't ask, it was over 10 years ago.
Admin
That'll pad right instead of left.
Admin
As awful as that function is, it would take a special set of circumstances for it to be the root cause of a null pointer exception. While it might be expected that it would either assert or throw a specialized exception on null argument, a string manipulation function shouldn't be required to silently ignore null string references.
Admin
It was supposed to be tongue-in-cheek. Sheesh.
Admin
Whoops. I'll do a quick fix:
Much better!
Admin
Sorry. On teh interwebs, we have still not sorted out tags for humor and irony.
Admin
I wonder what's wrong with:
Admin
C# isn't my native language, but I thought they didn't allow fall through. So you need lots of gotos.
Admin
The capitalized
String
should tip you off: it's Java…Admin
It's not C/C++, so no.
Admin
Pretty sure I got a capitalized S as an option in c#.
Admin
Admin
WAT?
Maybe, but no. The method capitalizations are wrong. The exception name is wrong. While yes, you could assemble this whole thing in C# if you wanted to and have it compile… No, you're just demonstrating your general ignorance.
Admin
Are you sure?
Admin
You're correct.
Mine has bugs too.