The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

The Intern

Last post 02-20-2013 5:08 PM by Zylon. 18 replies.
Page 1 of 1 (19 items)
Sort Posts: Previous Next
  • 02-19-2013 8:25 AM

    The Intern

    Our team hired an intern - mostly to save costs - with the intent of training him into a useful member of the team. This guy had just graduated, but claimed to have done several significant projects while in school. Ok, we didn't expect much, but what we got boggled the mind...

    As part of a routine code review, we found something he tried to integrate into the codebase:

    class Variables {
        public static int        classA_var1; // variable names annonymized
        public static String     classA_var2;
        public static double     classA_var3;
        ...
        public static Date       classB_var1;
        public static BigInteger classB_var2;
        ...
        // ~8,000 more lines of this
      }
    
      class A {
        public void someMethod() {
           Variables.classA_var1 = Variables.classB.var2;
        }
      }
    
      class B {
        public void someMethod() {
           Variables.classB_var1 = new Date();
        }
      }
    
      //...
    

    Pray tell, why did you make every single variable public static in what is effectively a class of globals?

    Because I needed to be able to change a private variable in one class from the other class, and Java only lets you pass variables by value.

    I weep for this industry.

    Be brief, no matter how long it takes.
  • 02-19-2013 8:50 AM In reply to

    Re: The Intern

    The problem is:

    Those who can, do; those who can't, teach

     

     

    At my workplace, I am the go to guy when it comes to Java/Object-Oriented, but you couldn't tell that from my university records: I almost failed intro to OOP class.

    Example of things I did on my project and exam:

    public SomeClass clone() {
      ...
      copy.stringField = this.stringField;

     

    What the professor wanted:

      copy.stringField = new String(this.stringField);

     

    I don't know how it is in the US, but here in Portugal we have a shortage of competent professors and TA's aware that teaching computer programming is more than explaining the rules of the language.

  • 02-19-2013 9:55 AM In reply to

    Re: The Intern

    Wow... and sometimes I worry about losing my job to younger programmers... ha!
  • 02-19-2013 10:10 AM In reply to

    Re: The Intern

    I don't get it...The professor is correct for many languages. You don't specify whether this was Java (like you are the "go-to" guy for) or some other language like C++...Where this would provide an appropriate deep-copy.
  • 02-19-2013 10:22 AM In reply to

    Re: The Intern

    Auction_God:
    I don't get it...The professor is correct for many languages. You don't specify whether this was Java (like you are the "go-to" guy for) or some other language like C++...Where this would provide an appropriate deep-copy.

    The difference is that in university the professor catches the subtle bug and takes points off, where in an enterprise environment no one notices and raises are given.

    Signatures are stupid.
  • 02-19-2013 11:03 AM In reply to

    Re: The Intern

    Auction_God:
    I don't get it...The professor is correct for many languages. You don't specify whether this was Java (like you are the "go-to" guy for) or some other language like C++...Where this would provide an appropriate deep-copy.
     

     

    Sorry, my bad. The course was Java only. When defending the project, I explained that Java String objects are immutable, but the TA insisted that I need to deep clone the String object otherwise "some other class will change its value" and the professor sided with the TA.

    On the paper-written exam I was deducted points for writting the opening curly brace on the same line as the method declaration/if statement.

    Feel free to take your conclusions...

  • 02-19-2013 11:27 AM In reply to

    Re: The Intern

     What's a TA?


    In complex analysis, a meromorphic function on an open subset D of the complex plane is a function that is holomorphic on all D except a set of isolated points

    Filed under:
  • 02-19-2013 11:35 AM In reply to

    • PJH
    • Top 10 Contributor
    • Joined on 02-14-2007
    • Newcastle, UK
    • Posts 3,836

    Re: The Intern

    dhromed:

     What's a TA?

    From the context I'm guessing 'teaching assistant.' I get the general impression it tends to be an older/graduated student seconded to the class, that is supposed to know better.
    "Because you watched 'The Very Hungry Caterpillar,' we recommend 'The Human Centipede.'"
    --
    UED - Countryside: To kill Piers Morgan
  • 02-19-2013 11:40 AM In reply to

    • locallunatic
    • Top 50 Contributor
    • Joined on 05-19-2010
    • (YourLocation==USA-KY?local:MisleadingUsername)
    • Posts 774

    Re: The Intern

    PJH:
    dhromed:

     What's a TA?

    From the context I'm guessing 'teaching assistant.' I get the general impression it tends to be an older/graduated student seconded to the class, that is supposed to know better.

    Yeah, TA is teaching assistant.  Most of the time they are a grad student, though sometimes for entry level classes they are undergraduates in their last year.  Sometimes they are just stuck correcting work or running help sessions before tests, but some schools use the grad student TAs to actually do the lectures for undergrad classes.

  • 02-19-2013 11:56 AM In reply to

    Re: The Intern

    snoofle:
    This guy had just graduated
    In my experience, guys who have just graduated are most often considerably better than people with anywhere between 3 and 18 months of experience. They haven't been ruined by a culture of mediocrity. My most successful project to date consisted of me (Tech Lead), a PM, and three fresh graduates who've never written a line of code outside of school. Obviously, you expect them to be a bit less productive in the first couple of months, but if they're provided ample time to study and enough guidance (I spent roughly 50% of my time in that project going between them and helping them wherever they were stuck), and of course proper code reviews, they can do a really good job.
  • 02-19-2013 2:23 PM In reply to

    Re: The Intern

    edgsousa:
    Feel free to take your conclusions...
    1. Your professor was a pedant with a 'my way or the highway' attitude,
    2. the TA had been indoctrinated by him,
    3. both were covering each other's ass and
    4. you should've put in a formal request for a second opinion.

    (Also, if the university does not give you the quite fundamental right to a second opinion, then WTF were you doing there?)

  • 02-19-2013 4:14 PM In reply to

    Re: The Intern

    configurator:
    snoofle:
    This guy had just graduated
    In my experience, guys who have just graduated are most often considerably better than people with anywhere between 3 and 18 months of experience. They haven't been ruined by a culture of mediocrity. My most successful project to date consisted of me (Tech Lead), a PM, and three fresh graduates who've never written a line of code outside of school. Obviously, you expect them to be a bit less productive in the first couple of months, but if they're provided ample time to study and enough guidance (I spent roughly 50% of my time in that project going between them and helping them wherever they were stuck), and of course proper code reviews, they can do a really good job.

    And you created a (small) cult of programmers who follow your methodology?

  • 02-19-2013 7:49 PM In reply to

    Re: The Intern

    In a Gaming/Simulation course (c programming), whenever my Instructor gave us code to work from, he'd make sure it's the worst code possible, with ineffiecencies, every variable global, failing to compile, and logic errors.

    His reason behind this is that he wanted us to know what it would be like in a worst case scenario in a Business Environment, and that understanding/refactoring the existing code is more important then just building new code blindly.

    At first I thought he was just lazy, but in the end I sort of agreed with the technique.

    Problem was, the people who slept through the first year and only started paying attention in the second year started learning...

  • 02-20-2013 1:43 AM In reply to

    • nic
    • Not Ranked
    • Joined on 11-04-2010
    • Posts 3

    Re: The Intern

    I'm demonstrating my technical ignorance, but as someone who has just graduated and have just noticed myself writing nearly exactly that above code style, what should I be doing instead? I have a list of variables that I need to access from other classes. So I've just been setting the variables as 'public static final VAR' and accessing them with CLASSNAME.VAR. What is a better way to do this? Or, alternatively, should I just stop trying to use globals and stick with locals and calling methods.
  • 02-20-2013 2:51 AM In reply to

    • Bulb
    • Top 500 Contributor
    • Joined on 07-29-2008
    • Prague, Czech Republic
    • Posts 216

    Re: The Intern

    Auction_God:
    I don't get it...The professor is correct for many languages.

    Any language where it is correct should be immediately forgotten. Mutable reference strings are a huge can of worms.

    Auction_God:
    …some other language like C++…Where this would provide an appropriate deep-copy.

    In C++, std::string is a value type. No new is, nor should be, involved.

    Auction_God:
    You don't specify whether this was Java…

    And C++ does not use .clone() methods. It uses copy-constructor and operator=. And C# uses .Clone(). Any other language is unlikely. So it must have been Java.

  • 02-20-2013 3:37 AM In reply to

    • PJH
    • Top 10 Contributor
    • Joined on 02-14-2007
    • Newcastle, UK
    • Posts 3,836

    Re: The Intern

    Bulb:
    And C++ does not use .clone() methods.
    Mummy, someone's wrong on the internet again!!!
    "Because you watched 'The Very Hungry Caterpillar,' we recommend 'The Human Centipede.'"
    --
    UED - Countryside: To kill Piers Morgan
  • 02-20-2013 8:42 AM In reply to

    • Zecc
    • Top 25 Contributor
    • Joined on 06-12-2007
    • and hasn't left since.
    • Posts 2,034

    Re: The Intern

    nic:
    I'm demonstrating my technical ignorance, but as someone who has just graduated and have just noticed myself writing nearly exactly that above code style, what should I be doing instead? I have a list of variables that I need to access from other classes. So I've just been setting the variables as 'public static final VAR' and accessing them with CLASSNAME.VAR. What is a better way to do this? Or, alternatively, should I just stop trying to use globals and stick with locals and calling methods.

    It's a bit hard to discuss this in abstract, but when you say you've got "variables that need to be shared between A and B", what you most likely have are either properties of A, properties of B or even properties of some other object C that gets passed around.

    There is no shame in creating a Context / Request / MyUseCase / StuffINeedForDoingThisThing class and storing your "variables" there, but you should instance it and pass it among the objects cooperating on your task. That is, as long as you don't get nuts and turn it into an EverythingContainer. You should remember the Single Responsibility Principle and create as many classes as necessary to structure your information cohesively.

    In the case of the OP, the guy should either create public setters in classes A and B; or pass a Variables instance to A#someMethod and B#someMethod. Judging by the names of the properties, the former.

    EDIT BEFORE EVEN POSTING: your case is different. Your variables... aren't. They're constants. They're final. And they are declared inside the classes they belong. You're doing it right.

     

    If mixed metaphors were illegal, I'd be having an indigestion.
    typeof NaN == 'number'
    var ò_ó, ಠ⁔ಠ, ᄒᆺᄒ, ᅙᅳᅙ, ᖛᨓᖜ, ꖴᅩꖴ, ఠᨋఠ; // Naming your variables is serious business
  • 02-20-2013 9:08 AM In reply to

    • Anketam
    • Top 150 Contributor
    • Joined on 10-12-2011
    • Nar Shaddaa
    • Posts 484

    Re: The Intern

    nic:
    I'm demonstrating my technical ignorance, but as someone who has just graduated and have just noticed myself writing nearly exactly that above code style, what should I be doing instead? I have a list of variables that I need to access from other classes. So I've just been setting the variables as 'public static final VAR' and accessing them with CLASSNAME.VAR. What is a better way to do this? Or, alternatively, should I just stop trying to use globals and stick with locals and calling methods.
    Depends.

     If the variable is associated with an object/class then it should be inside that class and thus not static (unless it is a constant).  If you seem to have a lot of variables that are not associated with any defined class, then you need to ask yourself if you are missing classes.  As for public, protected, and private it comes down to what should be allowed access to the variable.  You should take advantage of get and set functions (how they are done varies by language, and some languages have special support to make them slicker).  In my case I noticed that in my classes that variables used for storing data tend to be public while variables used for functionality tend to be private.

    Note that exceptions to this do apply.

    Project Manager: I don't know. I'm not allowed to talk directly to the customer. Apparently my grip on reality is too tight.
    - Weng
  • 02-20-2013 5:08 PM In reply to

    Re: The Intern

    snoofle:
    I weep for this industry.
     

    Since you're apparently stuck using Java, I'll weep right along with you.

     

Page 1 of 1 (19 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems