|
|
|
| Non-WTF Job: Software Developer at Rustici Software (Franklin, Tennessee) |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
classic ... so does that mean that that primitives are now references ... :-s
|
|
Wow, that's... deep, man.
|
|
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."
|
|
What's wrong? It just wastes some processor cycles, casting something as a String, then recasting it as a int...
|
|
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. |
|
dejavu - from my company ;)
|
Actually provided a "deep copy" of j, rather than i? That IS impressive. |
|
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".
|
int j = i; // provides shallow copy of i |
It only shows, as does your comment, a fundamental lack of understanding of the mechanics of the programming environment they're using. While this line is not outright erroneous, it allows us to extrapolate that the rest of the code is going to be chock full of idiotical cargo cult programming with hidden bugs - and, of course, a nightmare to maintain. |
"clbuttic", I suppose? |
|
I gotta ask - did they also do it for floats and doubles (which always resolve to an absolute value when converting to/from strings)?
|
Somebody's sarcasm detector is on the fritz. You should get that checked out if you are going to posting to an internet forum. |
|
I wonder what any declaration with a magic number would be like.
int i = int.Parse(12.ToString()); // global declaration |
I suppose the original code was also sarcasm, just a little joke the foreign programmers played on the foolish Americans while holding back the clean, competent, well-designed version to see how far they could take it? |
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 ;) |
"Those snotty Americans thinking they're all superior... If all foreigners write crappy code, then I might as well oblidge you. Here, see how fun it is to maintain this! muhahahahahahah!" |
Re: Deep Copy
2008-04-16 08:56
•
by
Roman Kennke
(unregistered)
|
Indeed. Parsing the string twice makes the copy even deeper. |
|
Perhaps it was providing a copy to someone named Deep?
|
I don't think there's anything on the original post keeping you from thinking that the code might have been outsourced to the Americans from, say, some small island in the Pacific (it's probably expensive to find programmers on Easter Island). |
|
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)); |
|
TRWTF is that it provides a deep copy of j not i.
Or maybe this is the difference to int j=i;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! |
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. |
|
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).
|
Epic fail |
Re: Deep Copy
2008-04-16 09:12
•
by
Edward Royce
(unregistered)
|
"idiotical cargo cult programming" Ok am I wrong to really like that phrase? |
The submitter's name hints towards the outsorcers being American. Nothing definitive, of course. |
|
This reminds me of some code we once had to write (for military security) to erase memory (pseudo):
Granted, this has an actual purpose, but still... memories! |
|
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. |
Re: Deep Copy
2008-04-16 09:24
•
by
I walked the dinosaur
(unregistered)
|
Of course...everyone over there is named Sandeep. |
While "idiotical" was my own addition, the term "cargo cult programming" is well established, probably because it's all too fitting and therefore likeable to people who's had to maintain code written in that mindset. |
|
Remember kids:
"Cheap Elbonian outsourcing companies suck because they are cheap outsourcing companies, not because they're Elbonians" </futile attempt to stop racism> |
|
Sorry to get serious here, but I am courious. The code:
int j = int.Parse(i.ToString()); // provides deep copy of j 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? |
Where? |
Hmmm, my father used to be nicknamed "Deep", and that was back in the 1930's. Maybe he was just way ahead of his time! |
Yes, it is valid c#. If I remember correctly, the primitives are auto-boxed. |
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()); |
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. |
|
If i is declared somewhere in scope, then yes it's valid C#.
but as previously pointed out they may mean j.ToString() |
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. |
|
"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* |
|
Not exactly similar, but I recently saw some code along the lines of:
if (i * 0 == 0) {i = j;} |
Don't forget "hidden bugs". As opposed to the ones in plain sight, you understand. |
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. |
|
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()"). |
"Have you tried rebooting, ma'am?" |
The funny thing is that if the compiler uses any optimizations, the compiled code would probably not be according to specs :o) |
Would everyone in Japan be Deep-san? |
It could make sense in a language with operator overloading (python or whatever...). |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |