1 month to train an intern part 2



  • Continuing from 1 hour to test intern's mettle where I selected my padawan, and training part 1, where I first measured his progress.

    As a reminder, the kid has 2 years of programming under his belt. Some PHP and C++ and only the very basics of javascript (eg. tell jquery to do shit). So I decided we should start from scratch.

    I gave him the Eloquent Javascript interactive book and he went on reading and typing out examples throughout the first week and a half of his residency. I stopped him 9 chapters in (right after regular expressions), as I deemed this deep enough to take a crack at node.js. I had planned a little test at this point, but I was too busy and he had some other tasks too, so it wasn't meant to be.

    Next, I gave him a few blog posts on node.js as a theoretical background. He read them and said he understood. Of course, he was lying. No one can truly understand node's style of asynchronicity until they experience it first hand.

    So finally, a week ago, we started with learnyounode, an excellent interactive node.js tutorial. He blasted through the initial few hello world snoozefests, and then ground to a halt when it came time to do modules and async. I helped him out a bit there, and we pushed through.

    He's pretty independent and will rarely ask for help, which is usually a good thing, but can also become a problem when he wastes hours doing the wrong thing.

    As expected, he was really struggling with the concept of node.js callbacks. Especially when I gave him a little curve-ball where he had to recursively walk a folder tree and rename some files. I had to guide him through to the end, but I don't fault him for that. Asynchronous recursion + array iteration is about as bad as the callback hell gets.

    Finally, today he finished the final, 13th, task and graduated as the fully certified node.js code-monkey, capable of taking on real tasks. Yeah, right. As long as he stays away from my real project. Luckily, we have just the perfect little side-project for him to truly test his mettle. He'll be starting with that from tomorrow.

    But before that, one last thing remained - the final exam. We both agreed he should take another crack at Mott's csv task (this time in node.js) and see if he does better than on the initial test.

    A quick reminder:

    PRODUCT            PRICE             QUANTITY
    Apple              0.75                 125
    Orange             0.80                 218
    Pear               0.99                 116
    Pineapple          1.75                 45
    Watermelon         1.15                 20
    
    In a language/IDE of your choice, read in the CSV file.
    Print the contents of the file to the screen, sorted by highest price first,
    and ignoring items with a quantity less than 50.
    

    This is the code he produced after about an hour of coding. The only intervention on my part was to explain to him javascript doesn't have native multi-dimensional arrays and he should do jagged matrix (how he didn't learn that by now is anyone's guess).

    var fs = require('fs');
    var path = "/home/intern/fruit.txt";
    var filtered= [];
    
    function readFile(path,callback) {
    	fs.readFile(path, function(err,data){
    		if(err){
    			return callback(err);
    		}
    		return callback(null,data);
    	});
    }
    
    function printFile(err,data){
    	if(err){
    		console.log(err);
    	}
    	filter(data.toString().trim());
    }
    
    function filter(file) {
    	var splitedFile = file.split("\n");
    	//spliting array on each line
    	var withSpace = [];
    	for (var i = 0; i < splitedFile.length; i++) {
    		withSpace.push(splitedFile[i].split(" "));
    	}
    
    	//make new filtered array empty
    	for (var z = 0; z < splitedFile.length; z++) {
    		filtered[z] = [];
    	}
    	//adding elements one by one in an empty array
    	for (var a = 0; a < withSpace.length; a++) {
    		for (var j = 0; j < withSpace[a].length; j++) {
    
    			if (withSpace[a][j] != "") {
    				filtered[a].push(withSpace[a][j]);
    			}
    		}
    	}
    	sort(filtered);
    }
    
    function sort(array){
    	var sorted = [];
    	sorted.push(array[0].join("\t"));
    	array.sort(function(a, b) { return (a[1] > b[1] ? -1 : (a[1] < b[1] ? 1 : 0)); });
    	for(var i=0; i<array.length; i++){
    		if(array[i][2]>50){
    			sorted.push((array[i].join("\t")));
    		}
    	}
    	console.log(sorted.join("\n"));
    }
    
    readFile(path,printFile);
    

    Impressions:

    • He finished the task. The program works. Good.

    • Uses English. With stupid var names and spelling errors, but oh well, at least it's progress.

    • Hard-coded path to the source file. I mean, OK it wasn't in the problem description, but IMO this is the kind of code smell a good programmer would sense a mile away. Especially disappointing since almost all examples from learnyounode used some kind of arguments input.

    • He's obviously impressed with callback style of node, but he still doesn't truly understand it. He has a chain of two callbacks that are completely useless. The meat of the program is standard synchronous code that prints to the stdout. I was hoping to see a better structure, but at least he's trying.

    • Missed return in the printFile's error handler. Since he had it in the other useless callback, I consider it a bug. Fair enough.

    • Idiotic for loop index names. Mental note, explain that he can reuse variables between the for loops. Also, that there's functional syntax too.

    • Has a useless z loop, to initialize empty arrays. Stupid and inefficient.

    • What's the point of calling sort(filtered)? You're printing directly to stdout and not returning anything. It's just the continuation of the code from filter(). It's like he knows he's supposed to separate code segments into different functions and tie them together, but still lacks the instinctive feel of why this is a good idea and how/when should he do it.

    • Figured out how sort works on his own. Good! But oh-oh. Are we comparing strings? What if prices are "2", "10", "1"? He got the correct output by accident. Mental note: always use the version of the problem with non-string-sortable values.

    • Luckily for him, js has his back in the filtering part and correctly coerces strings into integers. He had no idea. When they added all the stupid auto-correcting shit to js, I guess they had this level of coders in mind.

    Conclusion: progress! Not fantastic progress. But progress none-the-less.

    He'll be undertaking some real coding soon, so we'll see how he does. He's a cool kid so I'll try to help him along. Hopefully, in another week or two, he'll have enough to show for the boss to offer him a real job, with actual money involved.

    So far, A for effort, B- for results.



  • Man, I wish I'd gotten this level of training. For me, it went something like this:

    1. No programming xp besides GameMaker and WC3.
    2. Go to Uni, learn Java and get introduced to C, C#, Ruby, SQL, and Prolog.
    3. Return to the USA, can't find any positions, stay with my uncle (C# dev) who has me study the C# 1-2 language specs.
    4. Get a job for a government-ish power-ish company, to do enterprise xml and kml ish things using Enterprise Library. There learned how to use TFS wrong and how to do scrum wrong.
    5. Got a job at a place that insures funerals. Really. Using the original ASP .NET, Windows Server 2003, .NET 1.1, and an ancient version of Microsoft CRM, try to support their call center app. I hope they've realized that they can't keep customer data on that system come next year, since Server '03 is being retired. They decided they wanted to move to PHP.
    6. Got a good job at a company whose products everyone here has used. Learned how to do scrum right, and learned a lot about good software architecture (partly from the job, partly from this site, partly from Programmers.SE).

    Contracting for random recruiters is somewhat fun so far, really. I just wish I'd worked for a company that bothers training people before those first two.



  • @cartman82 said:

    Luckily for him, js has his back in the filtering part and correctly coerces strings into integers. He had no idea. When they added all the stupid auto-correcting shit to js, I guess they had this level of coders in mind.

    Unluckily, you mean? How's he ever going to figure out how to program effectively if he doesn't how what the hell is going on? Now he'll be really confused when this happens:

    @cartman82 said:

    Figured out how sort works on his own. Good! But oh-oh. Are we comparing strings? What if prices are "2", "10", "1"? He got the correct output by accident.

    PHP (also on his resume) pulls the same shit. Maybe that's why his code is so confused. The languages he's been using go out of their way to make programming confusing.



  • Man, that's pretty luxurious compared to me.

    1. The total sum of my programming xp was screwing around on a C64/C128 in BASIC during the late 80s, when I was knee high to a short grasshoppper.
    2. Well, that and some HTML3 in the 90s at High School.
    3. Eventually got sick of working as a cook, quit and found a drudge Data Entry job.
    4. DE job's software is shit. Shiiiiiiiiiiiiiiiit. 2012, and everything was badly made VB6.
    5. Kinda talked my way into updating their software for them.
    6. Learnt .NET on the job from a bit of trial+error and MSDN.

    I'm lucky in that apparently I'm good at this anyway, and my boss is really supportive and does her best to give me new challenges to keep me learning. Also everything we get from outsource is utter garbage.



  • This industry is wonderful. I'm always told how much trouble people have finding jobs, but I don't think they usually mean 'you have to wait 6 months, and then you will get calls all the time.'

    Now, I have a master plan for helping to fix this apparent problem in my country: teach everyone programming in school.

    'No!' you say, 'We don't need more noobs! Not everyone can do programming!'

    ...Which is exactly my point. Think of all the bad software that will be produced that we can all get hired to rewrite! It might really increase our value as people who can do it right.

    In essence, as things worth posting on this site increase, the value of people who can see what's wrong, post it here, and do it right increases.



  • @Magus said:

    Think of all the bad software that will be produced that we can all get forced to use! It might really increase our suicide rate.

    FTFY



  • True enough.



  • @cartman82 said:

    only the very basics of javascript

    In fairness, for most developers, that's all they need to know. Except the ones who are:

    1. Insane
    2. Really insane (aka using node.js)
    3. Douglas Crockford

  • BINNED

    @Magus said:

    ...Which is exactly my point. Think of all the bad software that will be produced that we can all get hired to rewrite! It might really increase our value as people who can do it right.

    If you increase the amount of people who can't program but are doing it for a living anyway, you also increase the subset of them who end up in management. They will be the decision makers and they are incapable of appreciating the value of people who can do it right.

    Also: http://en.wikipedia.org/wiki/Parable_of_the_broken_window



  • @powerlord said:

    In fairness, for most developers, that's all they need to know. Except the ones who are:

    Insane
    Really insane (aka using node.js)
    Douglas Crockford

    That world is fading away. Js is gaining traction at an incredible rate. Like it or not, it's becoming the new PHP - crappy language that people have to deal with.



  • @Magus said:

    teach everyone programming in school.

    I actually agree with this, but not for the reason you suggested:
    If people learn programming, they'll hopefully learn that computers are tools, not magic internet machines.
    It never ceases to confound me how people fail to realise the amount of menial work that can be automated with even the most rudimentary of scripts.


  • ♿ (Parody)

    How does this help me get more grumpy cat?


  • I survived the hour long Uno hand

    @cartman82 said:

    learnyounode, an excellent interactive node.js tutorial.

    My company's recommendation just came out. We recommend to the director of enterprise architecture that we move from Coldfusion to node.js. I think I'll go through this tutorial :)



  • No, it's becoming much more than what PHP ever dreamed of. Not only in the web, but also in hardware like FirefoxOS, Xbone, Smart TV (yes, JS, not Android) and other entertainment devices are using JS.



  • And then you have what Mozilla and Epic have been working on, getting Unreal Engine 4 to run in JS and WebGL...


  • Banned

    @trithne said:

    If people learn programming, they'll hopefully learn that computers are tools, not magic internet machines.It never ceases to confound me how people fail to realise the amount of menial work that can be automated with even the most rudimentary of scripts.

    Real life experience suggests otherwise - those who learn programming but are unfit to, not only don't actually learn anything even remotely useful, but also deepen their presumption that computers are magic (due to unobvious error messages the compier spits every time they make a mistake).



  • @Yamikuronue said:

    My company's recommendation just came out. We recommend to the director of enterprise architecture that we move from Coldfusion to node.js. I think I'll go through this tutorial

    Good for you. Note that you should probably brush up on your javascript skills too if you want any chance to keep your sanity as the codebase begins to grow.



  • For an intern that's not bad. We hired a number of interns at my last job that couldn't really do that.



  • @Gaska said:

    If people learn programming, they'll hopefully learn that computers are tools, not magic internet machines.It never ceases to confound me how people fail to realise the amount of menial work that can be automated with even the most rudimentary of scripts.

    Real life experience suggests otherwise - those who learn programming but are unfit to, not only don't actually learn anything even remotely useful, but also deepen their presumption that computers are magic (due to unobvious error messages the compier spits every time they make a mistake).

    See, as annoying as that is, I sort of understand the mindset. That's how I want things to work in areas that I don't care about. Tummy hurts? Take a pill doctor gave you and problem solved. Want to go somewhere? Sit in a magical machine, turn the key and drive. Full bladder? Press the button and the stuff disappears into the floor.

    And that's how I like it. I know I can save some money if I learned how to change the oil or fix the toiled plumbing myself. I don't care. I don't want to. It's worth for me to pay someone to take care of things, so I don't have to think about them. So I have more time to think about the things I DO care about.

    And other people are like that too, just for computers. They are not stupid (usually). It's just that a computer is like a toilet for them. All they want from it is to take a shit and move on with their life.

    Fair enough, I say.


  • Banned

    @cartman82 said:

    And that's how I like it. I know I can save some money if I learned how to change the oil or fix the toiled plumbing myself. I don't care. I don't want to. It's worth for me to pay someone to take care of things, so I don't have to think about them. So I have more time to think about the things I DO care about.

    Don't ever come to Poland. I left my car at mechanic's once because it needed urgent fixing. Week later they said they're done; they cashed equivalent of $300 (bear in mind average salary is 4x lower than in US), I drove the car home and only then noticed they fixed exactly nothing. Wasn't too surprised; this happens all the time in Poland, in nearly every industry. I was actually lucky they haven't stolen any of the good parts from my car!



  • @cartman82 said:

    Full bladder? Press the button and the stuff disappears into the floor.

    Sorry man, did the colonoscopy went so wrong they had to put you some pissing device?



  • @Eldelshell said:

    Sorry man, did the colonoscopy went so wrong they had to put you some pissing device?

    You don't want to know.


  • Discourse touched me in a no-no place

    @Gaska said:

    I was actually lucky they haven't stolen any of the good parts from my car!

    I assume it wasn't like that before the Soviets came along.

    (I am, ethnically, half Polish, and grew up in one of the areas of the US where Polish immigrants historically settled, so I have a little bit of interest in Poland. Would love to go there one day.)


  • Banned

    I'm far too young to remember what it was like before so-called communistic times.


  • Discourse touched me in a no-no place

    @Gaska said:

    so-called communistic times.

    O_o


  • Banned

    I assumed that by "before the Soviets", you meant before '45. In 45-89, Poland was CCCP's outskirts called Polish People's Republic which was communism-but-it-went-wrong-so-they-made-it-fairly-less-commie. In short, so-called communism.


  • Discourse touched me in a no-no place

    Ah, that makes sense. Yes, that's what I meant.


Log in to reply