- 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
classic ... so does that mean that that primitives are now references ... :-s
Admin
Wow, that's... deep, man.
Admin
A little more than three years ago, DPM's country decided to continue outsourcing a large portion of certain decision-making to a certain person many thousands of miles away from reality. "Even if their choices aren't as good," voters would often say, "we'll just re-elect them to decide it again. It'll still be less thinking on our part."
Admin
What's wrong? It just wastes some processor cycles, casting something as a String, then recasting it as a int...
Admin
That's not unlike what I've seen once:
int param = new Integer( paramString ).parseInt( paramString );
It gives your code a nice and unique twist.
Admin
dejavu - from my company ;)
Admin
Actually provided a "deep copy" of j, rather than i? That IS impressive.
Admin
Oh wow this is freaky because that is the same code that I posted to a forum to a question about holding a variable in memory. The chap seemed genuinely grateful when I responded to his request "to do the needful and plz email me teh codez".
Admin
Admin
Admin
"clbuttic", I suppose?
Admin
I gotta ask - did they also do it for floats and doubles (which always resolve to an absolute value when converting to/from strings)?
Admin
i //provides shallow copy of i
Admin
Somebody's sarcasm detector is on the fritz. You should get that checked out if you are going to posting to an internet forum.
Admin
I wonder what any declaration with a magic number would be like.
int i = int.Parse(12.ToString()); // global declaration
Admin
Admin
Ha ha. "do the needful"... Yeah, never heard that line before I got into this type of industry... Apparently, there is still some sort of language barrier, though. Here, I thought that "do the needful" meant "do everything that is needed to get the task done correctly, completely, and on time." But, what it actually means is: "do everything in the worst way possible while making sure only half the code works, half of the code is present, and the deadline is exceeded by a minimum of 1.5 months."
I never knew learning another language would be so darn tricky ;)
Admin
Admin
Indeed. Parsing the string twice makes the copy even deeper.
Admin
Perhaps it was providing a copy to someone named Deep?
Admin
Admin
That reminds me of some code I once saw. The code existed in a test case, but it still hurt my eyes.
The code that originally existed in the test case had these two lines (which seems unnecessary in itself): string val = "SomeValue"; string copy = (string)val.Clone();
Well, some developer removed that Clone line and replaced it with the following:
string copy = val + "x"; copy = copy.Substring(0, copy.Length - 1);
And then to cap it off... Debug.Assert(!Object.ReferenceEquals(val, copy));
Admin
TRWTF is that it provides a deep copy of j not i.
Or maybe this is the difference to
which would a (not so deep?) copy of i.Oh no! now I understand, this is code from the southern hemisphere, there lhs and rhs are reversed!
Admin
Wow... it this for real? I mean, maybe ONE person can fuck things up, but TWO in TWO lines of code? Yeah! It's traumatic, so much that you recall after it.
Admin
Too bad Alex doesn't quite grasp what "object oriented" means either -- otherwise he could never write such nonsense about OO and passing by reference vs. by value (hint: not related in the slightest).
Admin
Epic fail
Admin
"idiotical cargo cult programming"
Ok am I wrong to really like that phrase?
Admin
Admin
This reminds me of some code we once had to write (for military security) to erase memory (pseudo):
Admin
Well this kinda reminds me of my last job, which ended when the work got moved to India. The dev team in India decided instead of having all these pesky data tables they'd just format all the data into XML and then mash everything together into an enormous table with essentially 1 XML column.
Yeah ugly isn't the word for it.
Admin
Of course...everyone over there is named Sandeep.
Admin
Admin
Remember kids: "Cheap Elbonian outsourcing companies suck because they are cheap outsourcing companies, not because they're Elbonians"
</futile attempt to stop racism>
Admin
Sorry to get serious here, but I am courious. The code:
Is not valid java, it shouldnot compile for two separate reasons. Since I don't know c#, can someone tell me if this is actually valid code in any language?
Admin
Admin
Admin
Admin
Yep. "Valid" in C#.
But really, if you're going to do it right, you should take it seriously:
int j = System.Convert.ToInt32((string)int.Parse(i.ToString()).ToString());
Admin
More sarcasm? My sarcasm detector isn't quite sure on this one.
Value types and reference types are mentioned because of the "deep copy" comment. Value types don't need deep copied. Hence the humor? (We're forced to assume that i is an int here)
I must say though, if ever an int needed deep copied, this is a great attempt. :)
The only better solution I could think of would be to write i out to a file and read it back into j. That's uber deep.
Admin
If i is declared somewhere in scope, then yes it's valid C#.
but as previously pointed out they may mean j.ToString()
Admin
True. And I find that companies that use "cargo cult programming" also tend to use "voodoo tech support". That's when some unrelated change to a machine's configuration seems to fix an intermittent problem, at least temporarily, so that "fix" becomes the standard.
Admin
"but as previously pointed out they may mean j.ToString()"
urgh - I WTF'd my own entry! Dunno where that came form . Blame the excess of biscuits floating round the department today...
shoots self quietly
Admin
Not exactly similar, but I recently saw some code along the lines of:
if (i * 0 == 0) {i = j;}
Admin
Admin
Not sure if there was an error in transcription, but there is a lower case 's' on 'string'. Maybe they have their own string class and needed to check that it works properly. Still a WTF in either case.
Addendum (2008-04-16 10:22): I guess I don't know what language it is, so my comment might not apply.
Admin
This particular line of code is perfectly fine, the comment is incorrect. i can be an object, which is converted to a string and then to an integer.
int j = int.Parse(i.ToString()); // provides deep copy of j
(btw, it should start with lowercase "t" as in ".toString()").
Admin
Admin
Admin
Would everyone in Japan be Deep-san?
Admin
It could make sense in a language with operator overloading (python or whatever...).