• StMarc (unregistered)

    I had a friend who used to work for a very, very large medical equipment company (if you've been in a hospital in the last twenty years, anywhere in the world, the odds are even that you were relying on something this company made so you wouldn't die.)

    Right before he left, they started getting really, really into "process," and ISO-certification-on-steroids, etc. His manager said, with absolute sincerity:

    "If you have a good enough process, you don't have to have good workers, because as long as they follow the process you'll get good results."

    Keep in mind that my friend worked in the engineering design department, not, for instance, the assembly line or the building-maintenance office. (Not that good workers aren't important at all levels.)

    And people wonder why I would rather suffer than go to the hospital.

    M

  • Paul R. Potts (unregistered)

    Around 2001, I worked with an overseas development team that had utterly convinced themselves that there was something fundamentally wrong with the PowerPC architecture because it could not support a simple linked list traversal without crashing, so they were writing elaborate workarounds to avoid using a simple linked list of structures in C.

    The real answer was that they were using some kind of compiler flag on their Windows builds that automatically zeroed all allocated memory, and came to rely on this without even knowing that it was not standard behavior.

    Don't get me started on the guy who configured the CodeWarrior linker to suppress all multiple definition warnings, and then wondered why he got strange results.

    Yep, they were a bargain, and that's why I got paid to rewrite every line.

  • Math is hard Barbie (unregistered)

    Just like the major antivirus company I used to work for, I pointed things like this out to a VP, and his response was that the off-shore (not contracted, they were employees..) had added over 500k lines of code. I tried to say that LOC/SLOC is no way to measure quality or progress, but that fell on deaf ears.

  • spinfire (unregistered) in reply to snoofle

    Regarding the "mil spec" memory wiping:

    You know, the funny thing about that is if you don't use those values again later the compiler is perfectly free to optimize them away.

    A test with gcc 4.1.3 and -O2 shows the entire loop is gone.

    Older GCC (3.4.6) with -O2 just removes the second assignment, but keeps the outer loop. The inner loop is gone.

  • Ryan (unregistered) in reply to biziclop
    biziclop:
    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.

    I think maybe he thought that was multi-threading or parallel processing? You know, doing the same thing twice.

  • Schnapple (unregistered) in reply to CapitalT
    CapitalT:
    Remember kids: "Cheap Elbonian outsourcing companies suck because they are cheap outsourcing companies, not because they're Elbonians"

    </futile attempt to stop racism>

    I think with a few exceptions the comments on this thread are pretty level-headed, expressing disdain at the horrible logic of offshoring the work to the lowest bidder, especially on the flawed premise that the amount of time it will take to make it work has no value (and that the problems might be made better on successive rewrite iterations).

    But yeah it's all too easy to associate the offshoring with a race of people and wind up being racist against them. Especially if you don't know any Indian people (or live somewhere that isn't known for its diversity) and it seems like an especially foreign concept to you.

  • dkf (unregistered) in reply to buffi
    buffi:
    Anonymous:
    Not exactly similar, but I recently saw some code along the lines of:

    if (i * 0 == 0) {i = j;}

    It could make sense in a language with operator overloading (python or whatever...).
    It would also make (strange) sense when i is an IEEE float or double. Mind you, some compilers get IEEE math completely wrong anyway, so whether it would do anything remotely sensible is an open question...

  • tekiegreg (unregistered)

    I see this company is a believer in the "infinite monkeys" theory, so when applied to programming, if inifinite monkeys were given infinite time to write a program, could they eventually come up with code that could pass a unit test? Well if the time is infinite, perhaps the next MS Windows isn't too much to ask for :-)

  • Izzy (unregistered) in reply to olm

    often these memory-erasing routines were coded in assembler or machine code to avoid any compiler interface. Yeah, there were/are legitimate reasons for doing it because sometimes residual patterns in the computer can be detected from a good distance away. It's like using a router with the default password. Everything you do is public.

    Google "TEMPEST" from eskimo.com if you want to get really paranoid. The mil spec guys are paid to be paranoid and they're damn good at it.

  • (cs) in reply to brazzy
    brazzy:
    Zecc:
    brazzy:
    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?
    I don't think there's anything on the original post preventing you from thinking that the code was outsourced to the Americans...
    The submitter's name hints towards the outsorcers being American. Nothing definitive, of course.
    What if his name is like... Nathan Thakar. I once got a tech support guy for something (forget what) that said his name was Adam Chaturwedi. Another was Bruce Agarwal.
  • Torajirou (unregistered) in reply to buffi
    buffi:
    Anonymous:
    Not exactly similar, but I recently saw some code along the lines of:

    if (i * 0 == 0) {i = j;}

    It could make sense in a language with operator overloading (python or whatever...).

    I think you just gave an umpteenth proof that operator overloading is evil :)

  • Ashish (proud to be immigrant from thousand miles) (unregistered)

    So wht's the purpose of this article?

    wtf of CODE snippet or wtf of outsourcing.

    In my 9+ yrs of corporate client's systems development, i have seen this kind of bullshit code written by so called "native" here.. so don't show your frustration by finding out these kind of code.

    If your purpose is to show only "CODE" .. then u better change your way of writing article.

    In end, all i can say.. "shallow" article on deep code.

  • (cs) in reply to Ashish (proud to be immigrant from thousand miles)
    Ashish:
    In end, all i can say.. "shallow" article on deep code.

    Oh yes, very deep.

  • (cs) in reply to dkf
    dkf:
    buffi:
    Anonymous:
    Not exactly similar, but I recently saw some code along the lines of:

    if (i * 0 == 0) {i = j;}

    It could make sense in a language with operator overloading (python or whatever...).
    It would also make (strange) sense when i is an IEEE float or double. Mind you, some compilers get IEEE math completely wrong anyway, so whether it would do anything remotely sensible is an open question...
    (i * 0 == 0) is only true if i is a normal or a denormal number. If i is +Inf, -Inf, or NaN, it returns false. So yes, this code does do something useful: it detects non-sensible values of floats. Now why you're overwriting the sensible number is a matter of debate.

  • Anonymously Yours (unregistered)

    It's a shame you can't outsource middle management at a discount.

  • (cs)

    int j = int.Parse(i.ToString()); // provides deep copy of j

    Actually, there would be a temporary string variable with the formatted copy of the value of i (that is, the to be value of j), and that string would be placed deep in the stack. You couldn't do it better.

    Ok, what's my prize?

  • (cs) in reply to spinfire
    spinfire:
    Regarding the "mil spec" memory wiping:

    You know, the funny thing about that is if you don't use those values again later the compiler is perfectly free to optimize them away.

    A test with gcc 4.1.3 and -O2 shows the entire loop is gone.

    Older GCC (3.4.6) with -O2 just removes the second assignment, but keeps the outer loop. The inner loop is gone.

    If you declare 'memory' as volatile, gcc 4.1.2 with -O2 keeps the outer loop (as expected) and unrolls the inner loop.

  • Ashish (proud to be immigrant from thousand miles) (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    It's a shame you can't outsource middle management at a discount.

    LOL.. Outsource middle management and bring back programming here. That would be interesting to read blogs, comparing notes before and after.

    But

    1. By now, people here are used to make money on somebody's 80hr programming shifts.
    2. And they won't be able to host websites and make cheap adwords money.
  • topeka (unregistered)

    that's not right!! it's not like u go online dating at, say _ MILLIONAIRELOVES.COM _ with the thought of if this girl doesn't work out, i can always find the next one! that's very possible and not that costly!!

  • Cabalamat (unregistered) in reply to StMarc

    "If you have a good enough process, you don't have to have good workers, because as long as they follow the process you'll get good results."

    This could be called the Redundant Array of Inexpensive Programmers theory of project management.

  • Sanjay Kumar (unregistered)

    Racists, all of you.

  • Andrew (unregistered) in reply to Andy
    Andy:
    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?

    It may be valid Java. We don't know what type i is. If i is an Integer wrapper object, then this will work (sadly).

  • Sanjay Kumar (unregistered) in reply to Ashish (proud to be immigrant from thousand miles)

    Basically, they're haraam-zaade maan ke lodey.

  • ML (unregistered)

    I saw something similar once from an offshore developer. This was in a Java 1.4 (pre-Java 5) environment.

    /**
     * Makes a List of ProcessState out of a List of ProcessStateImpl
     */
    public List convertProcessStateList(List firstList) {
        Iterator iter = firstList.iterator();
        List secondList = new ArrayList();
    
        while (iter.hasNext()) {
            ProcessState ps = (ProcessState) iter.next();
            secondList.add(ps);
        }
    
        return secondList;
    }
    
  • Martin (unregistered) in reply to dpm
    dpm:
    Walleye:
    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.
    "Have you tried rebooting, ma'am?"

    That's not voodoo. That's Deep Magic!

  • LEGO (unregistered) in reply to Ashish (proud to be immigrant from thousand miles)
    Ashish (proud to be immigrant from thousand miles):
    So wht's the purpose of this article?

    wtf of CODE snippet or wtf of outsourcing.

    In my 9+ yrs of corporate client's systems development, i have seen this kind of bullshit code written by so called "native" here.. so don't show your frustration by finding out these kind of code.

    If your purpose is to show only "CODE" .. then u better change your way of writing article.

    In end, all i can say.. "shallow" article on deep code.

    The answer to your question, of course, is yes. The code is an obvious WTF, but the whole concept of of outsourcing to India/China/Russia/Elbonia runs contrary to a very basic principle of economics which is "you get what you pay for".

    The ability to create clean functional code knows no borders, but comes at a fairly uniform cost. Good programmers in India, for example, are now being paid wages much closer to their American counterparts. This is a natural result of the global demand for good programmers.

    Poor code, however, the type we are having fun with here, does come at a much lower cost from outsourced suppliers than from American labor who continue to demand a higher wage than their incompetent counterparts in other countries.

    The greater WTF here, is that companies are willing to tolerate the poor quality code, simply because it is attached to a lower price tag, with no regard for the greater overall costs that are imposed by this choice.

    As companies continue to become more familiar with the total cost of outsourcing I expect to see a commensurate increase in good 'ol American WTF's.

    --Lego

  • conservajerk (unregistered) in reply to Ashish (proud to be immigrant from thousand miles)

    I think the point of the article is a company cannot simply outsource to the lowest bidder and expect quality. You know the lowest bidder will cut corners to make his profit. I'm sure that cutting corners includes hiring less than experienced people and expecting them to produce.

    I've seen plenty of garbage like this in my career. Most of it was introduced by new grads/interns who were tasked with developing something beyond their abilities and experience by a company that wanted to save a couple bucks. The problem here is the belief by management that all programmers are created equal (ignoring experience) and that employee self-development/mentoring is not important.

  • Worf (unregistered) in reply to Izzy
    Izzy:
    often these memory-erasing routines were coded in assembler or machine code to avoid any compiler interface. Yeah, there were/are legitimate reasons for doing it because sometimes residual patterns in the computer can be detected from a good distance away. It's like using a router with the default password. Everything you do is public.

    Google "TEMPEST" from eskimo.com if you want to get really paranoid. The mil spec guys are paid to be paranoid and they're damn good at it.

    Well, an interesting use of a computer was to generate music without a soundcard or any digital to analog converters. In the Altair days, there was a program that would play "Daisy" if you ran it on the Altair and held a radio close by.

    So it isn't exactly paranoia, since people were using it for "useful" tasks. Though these days, the sheer number of computers makes it difficult (but not impossible, mind you) to actually single out the signal from one particular computer.

    Heck, a lot of cryptographic implementations can be broken by observing things like CPU power utilization (and being able to extract bits from the key this way). But this requires physical access...

  • Andy (unregistered) in reply to Andrew
    Andrew:
    Andy:
    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?

    It may be valid Java. We don't know what type i is. If i is an Integer wrapper object, then this will work (sadly).

    True, but i think the int.Parse(..) would also fail.

    And thanks for all the c# replies.

  • eryn (unregistered) in reply to Pope
    Pope:
    Andy:
    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?

    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());

    no, i'd feel much safer with:

    Int32 j = System.Convert.ToInt32((String)Int32.Parse(i.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

  • al (unregistered)

    I thought for sure this was the company I used to work for (complete with teams of developers in faraway lands), but then I realized it was deep copying ints. That's not nearly enterprisey enough, we deep copied XML, see:

    Document doc2 = Document.parse(doc1.getString());

    The need to copy ints never really arose, thanks to the universality of XML- we could use documents throughout the system!

  • Mike (unregistered)

    He ought to be sending it to a deep copy SOAP service, not doing this in-process data conversion... that's the real WTF.

  • Anon (unregistered) in reply to Edward Royce
    Edward Royce:
    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.

    Believe it or not, that was the way pushed by Microsoft when they came out with their amazing :rolleyes: "For XML" functionality in SQL Server. Dumbest implementation of XML in a database ever.

  • Chris Ovenden (unregistered) in reply to ljj116

    You're not thinking big enough: cast it to a string, wrap it up in a SOAP request, post it to a web service, which writes it to a database, then read back using another web service (via another SQL query), parse the returned XML, extract the required field, and run int.Parse() on that.

  • (cs) in reply to dpm
    dpm:
    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."

    This person speaks the truth.

  • Edward Royce (unregistered) in reply to FredSaw
    FredSaw:
    Edward Royce:
    brazzy:
    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.

    "idiotical cargo cult programming"

    Ok am I wrong to really like that phrase?

    Don't forget "hidden bugs". As opposed to the ones in plain sight, you understand.

    Actually I was thinking of having a t-shirt made "Participant in Cargo Cult Programming" with the picture of a guy with an old Apple II strapped to his head.

  • Harry (unregistered) in reply to ounos
    ounos:
    i //provides shallow copy of i

    More like a volatile copy of i on the processor stack.

  • Edward Royce (unregistered) in reply to Anon
    Anon:
    Edward Royce:
    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.

    Believe it or not, that was the way pushed by Microsoft when they came out with their amazing :rolleyes: "For XML" functionality in SQL Server. Dumbest implementation of XML in a database ever.

    Yeah that's a good name for it. Blew the database from 1.5gb to 30+gb in one shot. Plus it adds another 2-3gb per month just in empty rows, i.e. no data just XML docs containing nothing but column/field names.

    Then there's XQuery.

  • blarb (unregistered) in reply to Chris Ovenden
    Chris Ovenden:
    You're not thinking big enough: cast it to a string, wrap it up in a SOAP request, post it to a web service, which writes it to a database, then read back using another web service (via another SQL query), parse the returned XML, extract the required field, and run int.Parse() on that.

    Use the IntParse in Utils.cs instead. It leverages public static double Add(double[] valueArray) to build the integer one digit at a time with minimal rounding error.

  • Anonymous Cowardly Lion (unregistered) in reply to LEGO

    Add on to that the fact that companies think that they can get away with paying less for outsourced labor simply due to differing costs of living. Indian and Russian labor laws and market policies are severely restricting on business so the best jobs are invariably overseas for them. The best and brightest invariably migrate to wealthier countries with higher paying jobs available and only the worst stay behind. I believe that the phenomenon is called 'brain-drain,' and it explains that while India has one of the lowest GDP's per capita in the world, the Indian American population is one of the most successful and affluent demographics in the United States, surpassing native Whites by a wide margin.

    In short, I don't see how this is racist at all.

  • Anonymous Cowardly Lion (unregistered) in reply to LEGO
    LEGO:
    Ashish (proud to be immigrant from thousand miles):
    So wht's the purpose of this article?

    wtf of CODE snippet or wtf of outsourcing.

    In my 9+ yrs of corporate client's systems development, i have seen this kind of bullshit code written by so called "native" here.. so don't show your frustration by finding out these kind of code.

    If your purpose is to show only "CODE" .. then u better change your way of writing article.

    In end, all i can say.. "shallow" article on deep code.

    The answer to your question, of course, is yes. The code is an obvious WTF, but the whole concept of of outsourcing to India/China/Russia/Elbonia runs contrary to a very basic principle of economics which is "you get what you pay for".

    The ability to create clean functional code knows no borders, but comes at a fairly uniform cost. Good programmers in India, for example, are now being paid wages much closer to their American counterparts. This is a natural result of the global demand for good programmers.

    Poor code, however, the type we are having fun with here, does come at a much lower cost from outsourced suppliers than from American labor who continue to demand a higher wage than their incompetent counterparts in other countries.

    The greater WTF here, is that companies are willing to tolerate the poor quality code, simply because it is attached to a lower price tag, with no regard for the greater overall costs that are imposed by this choice.

    As companies continue to become more familiar with the total cost of outsourcing I expect to see a commensurate increase in good 'ol American WTF's.

    --Lego

    The previous was in response to this.

  • notJoeKing (unregistered)

    At my last employer, I "inherited" several forms full of gems like this from the programmer that had just left. My justification for redoing them all came early on when I found the following line of code: s = "Report Title".ToString.Trim

  • joe roberts (unregistered) in reply to Jeroen Brattinga
    Jeroen Brattinga:
    int j = i;    // provides shallow copy of i

    huh... is this sarcasm or have I just forgotten all of the first year in CS??

  • (cs) in reply to Andy
    Andy:
    Andrew:
    Andy:
    Sorry to get serious here, but I am courious. The code ss not valid java...
    It may be valid Java...
    True, but i think the int.Parse(..) would also fail. And thanks for all the c# replies.
    I also believe that since Java 5 Java does autoboxing of primitives, doesn't it? I haven't done any real Java since I left uni, and that was just as Java 5 was being released...
  • ML (unregistered) in reply to JimM
    JimM:
    Andy:
    Andrew:
    Andy:
    Sorry to get serious here, but I am courious. The code ss not valid java...
    It may be valid Java...
    True, but i think the int.Parse(..) would also fail. And thanks for all the c# replies.
    I also believe that since Java 5 Java does autoboxing of primitives, doesn't it? I haven't done any real Java since I left uni, and that was just as Java 5 was being released...
    Yes, but "int" is a reserved word used only to declare an int. It can't be used as a class name or an instance variable. Therefore, "int.Parse()" is syntacticly incorrect for Java and will not ever compile. Also, the uppercase ToString(), while possible to be Java, usually indicates C#.
  • Sanjay Kumar (unregistered) in reply to Anonymous Cowardly Lion
    Anonymous Cowardly Lion:
    ... I believe that the phenomenon is called 'brain-drain,' and it explains that while India has one of the lowest GDP's per capita in the world, ...

    This is the shallowest analysis ever. One has to go slightly deeper than that. One cannot simply attribute India's low per capita GDP to brain-drain. I'll leave you with a few reasons. (1) high rate of population growth (2) socialist policies founded in the past (3) diversion of India's resources, raw materials, etc to England in the 200 years of British rule causing India's GDP share in the world to lower from 25% when they arrived to less than 1% when they left; to enrichment to England and improvishment of India.

    With such attitudes and ignorance prevailing, is it any wonder that the author of this blog can make generally disparaging statements about an entire nation and get away with it?

  • David (unregistered) in reply to mb

    Oh no! now I understand, this is code from the southern hemisphere, there lhs and rhs are reversed!

    No buttwad, India is in the Northern hemisphere on the other side of North America - the Southern Hemisphere contains Africa, a very small part of South East Asia, Australia, New Zealand and South America (I've excluded Antarctica, but hey, maybe that's where you were suggesting this code was written).

    If you're going to make an insult get it right... either you are insinuating that this code was written by India/China/Vietnam/??? or it was written in one of the above mentioned areas - and apart from Malaysia or a dodgy con job in Nigeria, not too much gets outsourced to this direction.

  • (cs) in reply to akatherder
    akatherder:
    I wonder what any declaration with a magic number would be like.

    int i = int.Parse(12.ToString()); // global declaration

    Nope, integers have a maximum value, so to be on the safe side we can't write any numbers greater than 9.

    The above must be:

    int i = int.Parse((int.Parse(2.ToString()) * int.Parse(5.ToString())).ToString() + 2.ToString()) // i is deep copy of 12.

  • Gamma (unregistered) in reply to spinfire
    You know, the funny thing about that is if you don't use those values again later the compiler is perfectly free to optimize them away.

    One word: volatile

  • Dirk (unregistered) in reply to conservajerk
    conservajerk:
    I've seen plenty of garbage like this in my career. Most of it was introduced by new grads/interns who were tasked with developing something beyond their abilities and experience by a company that wanted to save a couple bucks.
    <rant> What's with the excuse that a grad can't be expected to do anything? I've seen time and time again just how useless a degree is. At one job a grad came on board as an intern and all he did was sit by himself working through a beginners C# book. WTF was he doing for the last 3 or 4 years? Why can't Universities actually teach kids to code so that they can hit the ground running?

    It just seems mind boggling that kids spend thousands on degrees to become programmers only to graduate and have to turn around and actually learn to program. WTF? </rant>

Leave a comment on “Deep Copy”

Log In or post as a guest

Replying to comment #:

« Return to Article