News for hackers. Stuff that matters.
Re:Some Developers Just Can't Develop by geebee on Sunday April 17, 2011 @03:15PM (#2456741)
"Now one of the things I was doing with new hires at the time was getting them to work on bugs – it helped me knock down the backlog and gave them exposure to a variety of areas across the system. I also gave them plenty of time early on to learn the ropes and get up to speed and it would typically take a few days to get through the first few bugs and start having some ah-ha! moments with the codebase."

This is a little bit of an aside, but how many people out there take this approach with a new hire? If you're a manager/team lead, do you start new developers out fixing bugs? If you're a developer, how do you feel when bug fixes are your first assignments?

Personally, I think that fixing someone else's bugs is one of the hardest tasks in programming. Depending on how the interview went, it can also be a very depressing and alarming task (autonomy? creativity, opportunity to influence the project? we've found that our recruitment success increased by 10% every time we used one of those words. now here's your task list, go fix some bugs).

I want to be sure that I emphasize that people have the right to pick their own management style, and I'm not questioning it. It also sounds like Richard was very reasonable about this - giving programmers adequate time to navigate the system (though "adequate" is a relative term... if "a few days" is enough for new devs to have their a-ha moments and fix several bugs, you probably have very high quality code and documentation).

But let's add this as reason #458 why young programmers prefer to start their own companies: their first "assignment" is creating a product, not fixing someone else's crap code.

Re:Some Developers Just Can't Develop by j_baker on Sunday April 17, 2011 @03:58PM (#2456858)
Well, two things:

1. It's a great way to learn a new codebase.

2. It's a good way to get some political capital so that you can get autonomy more easily.

You just don't usually start out with the plum assignments when you start a new job. If you do, you won't be given the autonomy to make them satisfying. So in my opinion, it's better to start off with jobs that you know will be drudgery to prove your worth than it will be to get a neat-sounding task where you'll be kept on a short leash.

Re:Some Developers Just Can't Develop by geebee on Sunday April 17, 2011 @04:55PM (#2456993)
Fair enough. I think this is an important thing for developers to understand about themselves before taking a job. Do I want to work with a large existing code base? Do I want to work for an organization where I need to build political capital to gain autonomy?

For some people, the answer will always be "no". For others, it's complicated, and potentially impossible to answer without trying out the company for a while.

Suppose the code is well organized and understandable. The bugs are not the product of bad design, they're just the inevitable side effect of any real software project. The programmers who created these bugs are largely still with the organization, they are highly competent, and are more than willing to help a new dev get up to speed - and the documentation (and code quality) is so good that it usually isn't necessary. Lastly, the team and management is eager to give autonomy and flexibility to a talented, proven dev, so it's not a problem to build up that "political capital" you mentioned. Well in this case, what you said is reasonable and more than acceptable to many good devs, even if it isn't right for everyone.

Then there's the nightmare scenario - the team is not highly competent, and the reason you were hired is that the good programmers keep quitting and there's nobody to help you. The code base is a mess, and documentation doesn't exist or is useless. Even getting a build to work is difficult and painful. The reason the management is giving you bug fixes is that they don't really know what to do with a new hire, so they assign some bug fixes, that'll keep you busy for a while. Lastly, they're aren't interested in listening to new suggestions, so political capital won't get you anywhere. O course, in this case, I suppose it doesn't really matter what your assignments are.

By the way, there is another way to get political capital. In my first real programming job, I had an almost ludicrous amount of autonomy. Like, "find something that might be useful and write software for it" levels of autonomy. This was the dot com boom, and there was enough money to hire people for this kind of thing. Of course, they didn't give me high impact assignments, but they did give me broad flexibility in meeting (and even determining) my assignments. This can be an alternate way to build up the political capital you mentioned. Instead of having a limited role on a high impact project, you have a broad role on a low impact project. That can work well for some people - however, these jobs are very rare. Usually, you have to trade the stability of a paycheck for that kind of freedom, especially early in your career.

Re:Some Developers Just Can't Develop by Groxx on Sunday April 17, 2011 @06:09PM (#2457169)
It's a great way to learn a new codebase if that codebase is well documented and explained to them. Otherwise you're just turning `if (i = 1)` into `if (i == 1)`, which may or may not actually be correct.

My current job had almost zero documentation anywhere, and nobody knew the entire system (or even the over-arching design, which I discovered was none). Which is starting to royally screw them over. And I started with a fairly highly integrated project. I learned it in spite of what I was doing in their system and lack of education for me (ie, zero), not because of it - they wanted things finished, I didn't want to finish them incorrectly.

Re:Some Developers Just Can't Develop by TillE on Sunday April 17, 2011 @04:08PM (#2456879)
You wouldn't want a new hire tackling some hairy mess of a bug. But this is common practice in open source projects - there's a massive backlog of minor bugs and nice-to-have feature requests, stuff that's pretty easy to finish if you had the time and the will.

Having someone take care of some of this stuff first to familiarize himself with the project and get used to the processes before jumping straight into a big task seems like a good idea to me.

Re:Some Developers Just Can't Develop by gnosis on Sunday April 17, 2011 @03:38PM (#2456802)
"Personally, I think that fixing someone else's bugs is one of the hardest tasks in programming. Depending on how the interview went, it can also be a very depressing and alarming task (autonomy? creativity, opportunity to influence the project? we've found that our recruitment success increased by 10% every time we used one of those words. now here's your task list, go fix some bugs)."

Indeed!

Many developers view fixing bugs as a punishment. Perhaps that is part of the reason why so much software is riddled with bugs.

Re:Some Developers Just Can't Develop by arethuza on Sunday April 17, 2011 @04:04PM (#2456869)
Does anyone else actually enjoy fixing bugs?
Re:Some Developers Just Can't Develop by gnosis on Sunday April 17, 2011 @04:13PM (#2456889)
Believe it or not, I do.

I really enjoy using various tools like static analysis programs and memory checkers to ferret out the offending bits of code, figuring out why they're broken, and fixing them.

It gives me a certain sense of satisfaction to finally conquer a bug. Particularly when it's a really tricky bug I've been bashing my head against for days.

Then again, when I've been after a given bug for days it can get really frustrating, and I don't enjoy the frustration.

And it's not like my dream job is doing nothing but fixing bugs. I also enjoy architecting new systems, learning new concepts, and applying them during the quest to complete a project.

I suppose a healthy mix of tasks, from architecture, to writing new code, to fixing bugs is ideal.

But what I really hate is writing documentation. I know it's necessary. And my (non-throwaway) code has quite a lot of comments in it because I know it's necessary and good practice. But it can get quite tedious.

I'd much rather bugfix than write documentation.

Re:Some Developers Just Can't Develop by Jd on Sunday April 17, 2011 @04:59PM (#2457001)
I completely agree about both bugfixing and documentation. That said, bugfixing someone else's crap code still sucks.
Re:Some Developers Just Can't Develop by kenjackson on Sunday April 17, 2011 @05:17PM (#2457046)
I love bug fixing too, especially if I have a good repro and its from a customer. Few things feel better than fixing a bug and delivering it to a customer.

I actually treat bug fixing as a little treat. When I want a break from coding -- I'll go and find a few bugs to fix.

Re:Some Developers Just Can't Develop by hasenj on Sunday April 17, 2011 @03:50PM (#2456840)
Specially when the code is legacy and rotten.
Re:Some Developers Just Can't Develop by X-Istence on Sunday April 17, 2011 @04:59PM (#2457000)
When I joined the company I am with right now, I wanted to jump into the codebase and start working on something, the way I get myself familiar with a codebase is reading the code, but it has to have a goal. I have to understand a piece of the code to use it (API with bad documentation), or because I need to fix a bug or add a feature.

I started working on the bugs by choice, it was an easier way to familiarise myself with the source code and gave me some problems that the other developers hadn't been able to fix, or hadn't gotten to yet.

Re:Some Developers Just Can't Develop by cfinke on Sunday April 17, 2011 @04:20PM (#2456907)
When I started at Netscape (the social news site, not the browser), I spent my first two days doing QA on the application, and I would heartily recommend having new hires do this. I got acquainted with all the aspects of the site, I didn't have to deal with other people's code (yet), and I gained that admiration and respect of my new co-workers by submitting a long list of bugs and XSS vulnerabilities that I found for them to fix. (Not really on that last part, but I don't think there were any hard feelings.)
Re:Some Developers Just Can't Develop by vimes656 on Sunday April 17, 2011 @02:52PM (#2456682)
As many blog posts this one focuses on the "false positive" candidates, the guys who get hired but turn out to be bad.

But I would be curious about the false negatives, the guys who were rejected (or almost rejected) but turned out to be truly good. Why they gave the impression they were bad in the first place? How did they proof the initial assumptions were wrong? What were they doing bad in the interview?

Does anyone have experience with these "false negatives"? How not to miss them in spite of a bad interview?

Re:Some Developers Just Can't Develop by bluesnowmonkey on Sunday April 17, 2011 @04:57PM (#2456997)
I've been a false negative several times, I'm sure. Here are some of the reasons why.

1. Poorly defined questions. One time, the interviewer kept referring to the browser as "the server" (in the context of a web app), despite my questioning him about it several times. After 5 or 10 minutes of trying to figure out what he even wanted, I told him I didn't want the job and ended it. From his perspective, he'd successfully weeded out an incompetent. From my perspective, I avoided working for someone with terrible communication skills.

2. Unclear objectives. One interviewer asked me to extend a small language by adding string support. No problem.

"OK, I'd start by modifying the parser."

"That's not what I had in mind."

"But that's clearly the first step. This isn't even a real language. What's the point here?"

"To get a feel for how you approach a problem in the real world."

"Well in the real world I'd modify the parser."

"Well just don't."

3. Pointless questions. "List some design patterns." Seriously? Sometimes my mind blanks on such questions. There's GoF over there on my bookshelf, and I could talk about the nuances of when and when not to use (almost) any particular pattern if they'd mention one, but from their perspective I know no design patterns at all. From my perspective, I'm glad I didn't end up working at a place whose screening process selects for rote memorization.

4. Insulting questions. "Write a for loop." I mean, I just told you I've been coding for 17 years. You're basically calling me a liar. I don't respond well to that. Enough of these and I might turn you down and walk out. A professional relationship (like any relationship) requires a certain amount of trust, so an interviewer this jaded/distrustful casts doubt on my ability to be accepted and productive there.

5. Trick questions. I hate them and I might have to count down from 10 if you ask me how many square manholes are in Beijing or whatever. You'll probably think I'm googling the answer.

6. The "figure out on the fly what I learned by reading a paper" question. Frequently I'll respond with a working but sub-optimal solution, then they'll prod me with hints until I come up with (or more often don't) the exact algorithm they had in mind. Sometimes they can't even explain what I need to improve about my answer, they just tell me to try something else. Sometimes this is the first question of the interview, and if I don't figure out the clever trick it becomes the only question, because they let me spend an hour banging my head against it without moving on. From their perspective, I answered zero questions and might not know anything at all. From my perspective... well I have no perspective by the end because I'm so tired and angry from being put through such a process.

Re:Some Developers Just Can't Develop by mavelikara on Sunday April 17, 2011 @09:59PM (#2457663)
Agree on 1,2 and 3 - they are jobs you don't want really.

I don't get offended by 4 (although I don't have 17 years of coding experience :); I understand the need for them to weed out the really incompetent ones. Think of this as a store clerk asking for your ID when you purchase cigarettes.

6 is, IMO, the biggest cause for false negatives. The interviewer feels that she gave ample hints, but really all she ascertained was that you did not have a crystal ball.

I also think that the interviewer anti-loop that Steve Yegge mentions (http://steve-yegge.blogspot.com/2008/03/get-that-job-at-goog...) contributes to the false negatives.

_Well, back when I was at Amazon, we did (and they undoubtedly still do) a LOT of soul-searching about this exact problem. We eventually concluded that every single employee E at Amazon has at least one "Interview Anti-Loop": a set of other employees S who would not hire E._

Re:Some Developers Just Can't Develop by kgrin on Sunday April 17, 2011 @05:34PM (#2457085)
RE #4 - note that the context here is the embarrassing inability of many applicants to, in fact, write a simple for loop.
Re:Some Developers Just Can't Develop by Tycho on Sunday April 17, 2011 @06:18PM (#2457189)
I suppose good developers should be glad when these basic questions come up in interviews, cause then we can rest assured that no incompetents are nicking our jobs (or warming the seats for a few months until they get sacked, thus slowing the hiring process down for everybody else).
Re:Some Developers Just Can't Develop by cpeterso on Sunday April 17, 2011 @10:13PM (#2457690)
Plus these questions can assure that you get hired to a team where everyone knows how to write a for() loop. :)
Re:Some Developers Just Can't Develop by pnathan on Sunday April 17, 2011 @10:48PM (#2457763)
Oh, goody. I would feel assured that I would work with people at the level of CS 1, as a professional.
Re:Some Developers Just Can't Develop by lutorm on Sunday April 17, 2011 @06:29PM (#2457205)
You can't write about the people who weren't hired... There's a strong selection effect here.
Re:Some Developers Just Can't Develop by Confusion on Monday April 18, 2011 @01:26PM (#2459850)
There may be interesting anecdotes where people run into rejected candidates at some later time, to learn they were actually quite competent.
Re:Some Developers Just Can't Develop by gaius on Sunday April 17, 2011 @03:22PM (#2456758)
We phone screen candidates and you would be astonished how often you'll ask a basic question then the phone goes dead silent (i.e. on mute) then 20 seconds later he's back and rattles off an answer. Sometimes they don't even mute and you can hear the keyboard clicking as they desperately Google. Sometimes while doing the phone screen I Google, and read what they've just said from the top result back to them, y'know, for lulz.

These days there's so much content around that some people in surprisingly senior positions can wing it, Googling some stuff then c'n'p, and slyly passing the rest to cow-orkers, at least for day-to-day tasks, and at least in the short term. Then one day everyone's busy and Jo(e) Faker has to do some real work.

But you've got to watch out. The very slyness that makes them do this will also get them promoted to management...

Re:Some Developers Just Can't Develop by jarpadat on Sunday April 17, 2011 @03:49PM (#2456834)
The joke's on you if your interview process consists of asking googleable questions.

Asking "Define X" questions is a really bad proxy for assessing development skill. If you think developers are winging it by c'n'p--any interviewer who asks the candidate to produce a bunch of facts for an hour is the same, if not worse. You don't interview a classical pianist by asking him what notes are on the keyboard.

Re:Some Developers Just Can't Develop by gaius on Sunday April 17, 2011 @05:01PM (#2457007)
The questions are on an ascending scale - this weeds out the bad candidates early on. Things like keywords and syntax are easily Googlable sure, but people who really do this stuff every day will rattle through that section of e interview in 5 minutes.
Re:Some Developers Just Can't Develop by kariatx on Sunday April 17, 2011 @08:44PM (#2457506)
Many years ago, I had a friend who was trying to schmooze her way into a development position hoping to "learn on the job." Anyway, she was stunned and even angry that she was asked technical questions during the initial phone interview.

Before hearing her story, I was skeptical that anyone tried to pull this crap. She's now in a field (marketing) where she can put her slyness to more use.

Re:Some Developers Just Can't Develop by code_duck on Sunday April 17, 2011 @02:48PM (#2456672)
I hear this a lot. Which attractive positions can I apply for where my competition will be people who can't code a CSS rule for a class versus an ID? Are we really trapped in a competency bubble on sites like HN and don't realize the vast incompetence of the majority of computer professionals?
Re:Some Developers Just Can't Develop by cpeterso on Sunday April 17, 2011 @03:34PM (#2456790)
I read about (and have interviewed a few) "developers who can't develop". Is this phenomenon unique to the software industry, since it has no formal licensing boards and the technology changes so rapidly? I can't imagine doctors who don't know medicine or lawyers who don't know the law.

The lesson is that interviewers must give coding questions even to "senior" developers. See, for example, the "FizzBuzz" interview question:

http://www.codinghorror.com/blog/2007/02/why-cant-programmer...

Re:Some Developers Just Can't Develop by code_duck on Sunday April 17, 2011 @04:16PM (#2456897)
I've run into doctors, specifically a psychiatrist or two, who have not kept up with changes in their fields. Considering psychiatry is fairly fast moving, that's somewhat like if one went to college in the 80s and learned COBOL and DOS, and glossed over everything since then. Definitely harder to get away with doing that as a lawyer, though!
Re:Some Developers Just Can't Develop by cpeterso on Sunday April 17, 2011 @10:02PM (#2457667)
To remain certified, MDs must taking Continuing Medical Education classes every year and a recertification exam every 6-7 years (I think). I believe attorneys have some similiar requirements
Re:Some Developers Just Can't Develop by bobds on Sunday April 17, 2011 @04:10PM (#2456883)
> I can't imagine doctors who don't know medicine or lawyers who don't know the law.

Oh there's plenty of quacks and shysters out there. I've met some of them.

Re:Some Developers Just Can't Develop by perlgeek on Sunday April 17, 2011 @05:17PM (#2457044)
I've had a teacher who didn't know here subject (Chemistry), and opened the textbook to answer very basic questions that I (merely interested in Chemistry, haven't studied it) could have answered without.

I was very shocked because in Germany you actually have to a good part of the Chemistry studies at University to be allowed to teach it. I wonder if she forgot it all in the mean time, or if she had gamed the system somehow.

Re:Some Developers Just Can't Develop by alex_h on Sunday April 17, 2011 @03:58PM (#2456861)
Assuming these inept candidates are not Frank Abagnale types just doing it for the thrill, I wonder how they are expecting the job to actually turn out. I mean what was the guy expecting to do all day if he couldn't write a single line of code?
Re:Some Developers Just Can't Develop by X-Istence on Sunday April 17, 2011 @05:10PM (#2457024)
But Frank Abagnale proved that he was at least able to learn as he was going along, like he studied for and passed the bar.

I think it would be interesting to work with someone like that, especially in software, you can mould them to anything. Would I enjoy it for the first couple of months? Probably not, but clearly not everyone you hire has to be excellent, sometimes you just need people that learn fast and are able to pick up new things easily.

Re:Some Developers Just Can't Develop by xsmasher on Sunday April 17, 2011 @08:32PM (#2457476)
Dunning-Kruger I presume; they may assume that everyone programs by copy-paste or trial-and-error.
Re:Some Developers Just Can't Develop by _stephan on Sunday April 17, 2011 @04:17PM (#2456901)
I have a hard time believing that you can't detect that someone has absolutely no clue about programming just by asking about his past projects, drilling down on some specific technical challenges he encountered during those projects, quizzing him about his preferences for programming languages, libraries and stuff like that.
Re:Some Developers Just Can't Develop by watmough on Sunday April 17, 2011 @07:26PM (#2457349)
Some people have a very narrow experience, but within that experience, they can actually be pretty darn good programmers.

I worked with a bunch, none of whom ever ventured outside of Visual C++ and SQL, and who would never have even heard of Ruby or Python or Clojure. Despite this, they could still knock out pretty decent real-World code.

In that case, it can be difficult to filter out the bad ones, just based on general conversations, without asking people to actually code on a blank board.

Re:Some Developers Just Can't Develop by dspillett on Sunday April 17, 2011 @03:23PM (#2456763)
Ah, memories of the tool whose CV stated "Javascript: Advanced" and "jQuery: Intermediate" but who asked me to explain what the $ was in some code... It took far too long for us to convince management to get shot of that one.
Re:Some Developers Just Can't Develop by Joeboy on Sunday April 17, 2011 @05:15PM (#2457039)
In many js libraries $ is an alias for document.getElementById, whereas in jQuery it's an alias for jQuery. It might have been a reasonable question to ask.
Re:Some Developers Just Can't Develop by dspillett on Monday April 18, 2011 @06:43AM (#2458598)
Not for someone who is "intermediate" in jQuery.

He didn't even recognise $ as a valid function name which rules out exposure to other libraries mapping it to different behaviours, and the use of an anonymous function (remember: this is someone who claimed to be "advanced" in Javascript) really blew his mind.

Re:Some Developers Just Can't Develop by russell on Sunday April 17, 2011 @03:31PM (#2456785)
A couple of decades ago, I first ran into the professional incompetent, someone who can have 8-10 years of good experience without having accomplished anything. She (sex means nothing, just tweak the adjectives) was attractive, intelligent. articulate, easy to work with, but thoroughly incompetent. She was assigned to do a piece of one of my projects. I worked with her for a month but she couldnt get anywhere, an the VP insisted that I work with her. Finally I isolated her code and spent a day implementing the task. After a couple of years she was canned.

The professional incompetent part? She had had the same kind of two year stint for 10 years. I'm glad she wasnt y hire.

Re:Some Developers Just Can't Develop by 16s on Sunday April 17, 2011 @03:40PM (#2456807)
Have them write FizzBuzz (or something similar) give them 15 minutes to do it (more than enough time). Leave the room so they don't feel pressured. Offer them the OS and compiler of their choice. Ask them to write it in two or three languages, but only one is OK if they run out of time.

If they write something that compiles, give them a point. If it is well commented, give them another point. If the results are correct, give them another point. More than one language would get another point as would finishing early, etc.

It's pretty easy to weed-out people who cannot program by doing this and it doesn't take that long.

Re:Some Developers Just Can't Develop by patrickyeon on Sunday April 17, 2011 @04:00PM (#2456866)
I sympathize with interviewers who would rather be there while the potential hire writes. Have them talk through what they're doing, why they're making choices, where they're worried about, etc so that you can get a feeling for how the person thinks.

On another matter, I wouldn't be surprised if nobody worth their salt commented FizzBuzz; there's just not a level of complexity that you can better describe in English than in code.

Re:Some Developers Just Can't Develop by ericd on Sunday April 17, 2011 @05:01PM (#2457004)
Yeah, I'd think it was a bit silly if someone spent time commenting Fizzbuzz...
Re:Some Developers Just Can't Develop by tjarratt on Sunday April 17, 2011 @05:14PM (#2457032)
What exactly would "well commented" mean for fizz buzz? One of my pet peeves are devs that comment insane things that should be obvious from reading the code.

eg:

#save the model and pass along a callback model.save(callback)

If you were writing code that was as simple as fizz buzz, would you really write any comments at all?

Re:Some Developers Just Can't Develop by 16s on Sunday April 17, 2011 @07:14PM (#2457319)
Just my opinion, but here are my comments to FizzBuzz.

https://github.com/16s/FizzBuzz/blob/master/FizzBuzz.cpp

Re:Some Developers Just Can't Develop by BSousa on Monday April 18, 2011 @03:47AM (#2458333)
A few notes on this:

1) and keyword for c++ ? It has been a while since I used C++ but it used to be &&. Did it change (I'm actually asking, not being sarcastic).

2) on the 'else if' parts, you only need to do one evaluation (the == part) since the first if tests for both % 3 and % 5 so no need to do != on % 3 or % 5 as you know it will never be true.

3) honestly, I think the comments make it worst. If a programmer doesn't know by just looking at the code what it does, no amount of comments will help him.

Re:Some Developers Just Can't Develop by Confusion on Monday April 18, 2011 @01:35PM (#2459886)
I don't think those comments are very helpful. I think a function-level comment would be much clearer.

  # Outputs 'Fizz' when +arg+ is divisible by 3, 'Buzz' when
  # it is divisible by 5 and 'FizzBuzz' when it is divisible
  # by both 3 and 5.
Re:Some Developers Just Can't Develop by 16s on Monday April 18, 2011 @04:44PM (#2460554)
That's a matter of opinion. I always do this. Now there is no question what each conditional is intended to do. So if I make a mistake, you can clearly see from the conditional comment what I meant to do.
Re:Some Developers Just Can't Develop by danielharan on Sunday April 17, 2011 @05:28PM (#2457073)
Exactly. That kind of comment is worse than useless.

I'd rather see tests than comments.

Re:Some Developers Just Can't Develop by hasenj on Sunday April 17, 2011 @03:51PM (#2456845)
The OP does mention that.
Re:Some Developers Just Can't Develop by brendoncrawford on Sunday April 17, 2011 @09:56PM (#2457658)
Obligatory obfuscated FizzBuzz python solution:

    ###################################
    import sys;map( sys.stdout.write,[#
    ''.join(map(chr,([0x46, 0x69,0x7A,#
    0x7A,0x42,0x75,0x7A,0x7a] if not i#
    %0x0F else[0x42,0x75,0x7A,0x7a] if#
    not i%0x05 else[ 0x46, 0x69, 0x7A,#
    0x7A] if not i%0x03   else[int(c)+#
    0x30 for c in str(i)  ])+ [0x0A]))#
    for i in xrange(     0x01, 0x65)])#
    ###################################
Re:Some Developers Just Can't Develop by watmough on Sunday April 17, 2011 @07:07PM (#2457292)
Yeah, it's true, but many of them are able to prosper in large systems where lots of code can be copy-pasted around.

Here's my string reverse. Actually, it might be the first damn time I've ever reversed a string in code. Thoughts.

  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  
  int main (int argc, const char * argv[]) {
  	
      /* alloc mem so we can reverse in-situ */
  	const char * s  = "reverse me 123";
  	char * rev = malloc(strlen(s));
  	strcpy( rev,s );
  	
  	/* reverse the string 'in'  */
  	for( int i=0 ; i<strlen(rev)/2 ; ++i )
  	{
  		char tmp  = *(rev+i);
  		*(rev+i) = *(rev+strlen(rev)-i-1);
  		*(rev+strlen(rev)-i-1) = tmp;
  	}
  	
  	printf("string: %s  reversed: %s",s,rev);
  }
Re:Some Developers Just Can't Develop by palish on Sunday April 17, 2011 @08:25PM (#2457452)
Bug #1:

  char * rev = malloc(strlen(s));
... It should be malloc( strlen(s) + 1 ) to include the NULL terminator.

Nitpick #1:

  char tmp  = *(rev+i);
should be

  char tmp( rev[i] );
Nitpick #2:

  i<strlen(rev)/2 ;
"strlen(rev)" is evaluated every iteration of the loop.

Nitpick #3:

  *(rev+i) = *(rev+strlen(rev)-i-1);
  *(rev+strlen(rev)-i-1) = tmp;
Those two strlen(rev)'s are evaluated every iteration of the loop.

Why not write it like this?

  for ( int i(0), iLen( (int)strlen(rev) );
        i < (iLen / 2);
        ++i )
  {
      Swap( rev[i], rev[iLen - 1 - i] );
  }
  }
Re:Some Developers Just Can't Develop by cpeterso on Sunday April 17, 2011 @10:51PM (#2457770)
1. `char tmp( rev[i] );` is valid C++, but not C.

2. Your for() loop is still dividing `iLen/2` every iteration. Presumably the compiler would hoist the division out of the loop, but the code would still add some cognitive friction to future readers of this function. :)

Here's my attempt:

  void strrev(char* s)
  {
      char* a = s;
      char* z = s + strlen(s) - 1;
      while (a < z)
      {
          const char c = *a;
          *a = *z;
          *z = c;
          a++;
          z--;
      }
  }
Re:Some Developers Just Can't Develop by watmough on Monday April 18, 2011 @01:21AM (#2458069)
This is the one I like. :D

I have interviewed people, but I gave up asking coding questions, since no one could ever do them. And if you keep thumbs-downing people, you don't really get invited to interview any more people.

Thanks again!

Re:Some Developers Just Can't Develop by palish on Sunday April 17, 2011 @11:48PM (#2457868)
Surely that's less clear than "Swap( rev[i], rev[iLen - 1 - i] );"?

And yes, the compiler would optimize out "iLen / 2", computing it once rather than every iteration.

Re:Some Developers Just Can't Develop by watmough on Monday April 18, 2011 @01:17AM (#2458062)
Bug #1, Haha. I deliberately didn't do any polishing. I just C-P the first thing that compiled without warning and ran the embedded test case.

Not so sure about nitpick #1. I'll need to pull out K&R...

nitpick #2, sure.

nitpick #3, is that really what idiomatic C looks like? Yikes.

Re:Some Developers Just Can't Develop by rorrr on Sunday April 17, 2011 @05:20PM (#2457059)
I've written about this a few times before. I've done many interviews over the last 2 years. Before I started at that company, their interview process was pretty much as the article described.

We started by designing a set of technical interview questions. A few simple ones, like reverse a string. A more complex ones, like reverse digits in an integer. And then even more complex and practical ones with algorithms, but still very trivial. At first another developer and I thought they were too easy.

When we started interviewing, we made a shocking discovery that around 90% of the candidates can answer even simple questions. Very few people can write a correct function to reverse a string. Just think about it. These are the people that will have to write complex production code.

Out of 50 people I think we had one guy who answered all the questions. A few times we allowed candidates to use their laptops (it was their choice), one candidate spent like 30 minutes writing the reverse function, didn't really help him.

Our success rate was pretty much 100%, we have not hired one bad developer.

TL/DR: always ask interviewees to write some code.

Re:Some Developers Just Can't Develop by 3pt14159 on Sunday April 17, 2011 @06:46PM (#2457245)
What language was this in? In ruby this would just be "hello".reverse, and even if you didn't have that available to you there would always be:

  acc = "" ; "hello".size.downto(1) {|i| acc += "hello"[i-1]}
or the more rubyist way of doing it

  "hello".each_char.to_a.reverse.join
Or probably something more clever I can't think of at the moment. Was the language so crippled that they were worrying about UTF8 characters? It can't possibly be that 95% are that bad. How could they possibly do anything?
Re:Some Developers Just Can't Develop by rorrr on Sunday April 17, 2011 @10:03PM (#2457670)
Sorry, didn't answer your question fully the first time, was in a rush.

The languages we interviewed for were Javascript and PHP (for different positions). There are lots of newbies out there who pick up the basics of these two languages (due to their popularity), and then try to get high paying jobs. Most of them are used to copy/pasting the code from the internet.

That's extremely prevalent among Drupal developers. Drupal has a ton of contributed modules, so you can get pretty far without writing a single line of code. It's really really hard to find a good Drupal developer.

I'm completely serious about 90% not being employable (by my standards).

Re:Some Developers Just Can't Develop by rorrr on Sunday April 17, 2011 @06:59PM (#2457271)
We ask not to use the built-in reverse function.

And for the number reversal we ask not to fall back to strings.