Live data from Hacker News

Ask HN: What did I do so wrong in this coding interview

news.ycombinator.com

61–70 of 98 posts

Re: Ask HN: What did I do so wrong in this coding interview

#61
post #38

Without seeing the prompt they gave you and not knowing the context you would have gained from the technical interview, we're all just guessing here. My guess is that they were expecting a much simpler application for a simple problem. Also for a JS game with a tiny backend, the Github project code is heavily weighted toward PHP (73% PHP vs 20% JS). Perhaps in their internal discussions, a word like "over-engineered"…

It's clear that their stack is not PHP from honestfeedback's comment about not being familiar with composer (though really composer does not require sudo if used properly). From briefly glancing at the code, I also think it looks fine and for a one to two hour project, IMO, is way more than any company should expect. I agree that knowing the answers to these questions is crucial regardless of coding tests, but an interviewer who can't judge code that's not in a familiar format (MVC, framework, etc.) is a junior developer and shouldn't be judging any code.

I hope the OP finds a job someplace where his skills will be appreciated, a place that doesn't ask for free work. Sounds to me that they were really too lazy to look at the whole application or didn't have the technical know-how to understand an application written in frameworks they were not familiar with.

Re: Ask HN: What did I do so wrong in this coding interview

#62
post #39

Agreed w/ honestfeedback. - Overall project structure seems a bit unorganized IMO (no centralized build process, gulpfile inside subfolder). Overall this makes it fairly hard to dive right into the project. It might be my lack of experience in PHP project structure. - I think pulling in a server & a db might be an overkill. Local storage will do the job perfectly. - Mix of tabs & spaces is also very messy. - Styling…

> - Overall project structure seems a bit unorganized IMO (no centralized build process, gulpfile inside subfolder). Overall this makes it fairly hard to dive right into the project. It might be my lack of experience in PHP project structure.

This was what I noticed the most - and I can easily see this as a big part in the discussion, since seniors should lead and bootstrap projects.

I'd have expected something like ./server and ./client and a README toplevel, client eventually having a public folder which can be served as-is (i.e. doesn't contain any build/dependency management files), potentially with a second public-minified around. Instead I end up with a src-folder hidden like 3 folders deep and another one toplevel for asymmetry.

Beyond that, the folders in the php app follow the package-by-kind antipattern. There is no value in grouping all controllers in one place. There's value in grouping all the highscore handling in one place, though.

Re: Ask HN: What did I do so wrong in this coding interview

#63

1. When your comments are longer than your code, either you're putting in too many comments, or your code is too hard to read. (The former seems to be the case here.) 2. Why is the spacing convention all over the place in some files? https://github.com/m4nuC/memGame/blob/master/app/controllers... https://github.com/m4nuC/memGame/blob/master/app/database/mi... 3. Why are there so many folders that only have .gitignore…

> 1. When your comments are longer than your code, either you're putting in too many comments, or your code is too hard to read. (The former seems to be the case here.) I hate this meme. There's nothing wrong with too much commentary. You are not on a comment budget. Please stop spreading this around, like the "rewriting is always a bad idea" meme that's embedded itself in young developers like dogma even though Spol…

I think you might've misunderstood what I'm saying. It's perfectly fine to have complex functions commented as much as necessary; heck, it's totally fine to have your comments be 100x as long your function when the function is actually hard to understand.

What's not OK is commenting ALL of your code, especially not to such an extent where the comments are actually longer than the code size on average. (!) Some stuff just has to be self-explanatory, period -- that's a fact, not a meme. If you can't make the simplest code self-explanatory, then I'm sorry but you simply can't code as well as someone who can. And if you're going to comment everything, then you're also wasting valuable time that someone who didn't need to do so would've spent writing actual code and getting more done.

Re: Ask HN: What did I do so wrong in this coding interview

#64
post #32

Disclaimer: I'm posting this under a new dummy account because I don't want this to be seen as feedback from my company. We didn't interview you, but I'm a senior manager and I want to help w/o implicitly dragging my team into it. (The key word is also "help"; I'm not trying to belittle you, just give my honest assessment of this project, quick as it was to create.) tl;dr: I agree with the assessment that this doesn'…

So using abstraction is not something a senior does ? It seems to me like the contrary. The more experience I have the more I like to abstract things instead of making them from scratch. But even so it seems a bit heavy of judgement to disqualify me with such strong word over this choice.

There's nothing wrong with abstraction. But you should use the right abstraction for the job. You don't need a huge PHP web framework, tons of dependencies, an entire package manager, sudo access, and so on to have a simple memory game with a high score backend.

Remember, when you're looking for a job, you're not looking to create some build and forget application. You're going to be working as part of a team. Other people need to be able to maintain your code. For a problem that should be able to fit onto a single page, you don't want to have to browse through a 7 megabyte git repo with nearly 10,000 files in it.

An analogy might be if someone's trying to hire you as a carpenter. They ask you to build a cabinet to demonstrate your skill. You go and find a prefab house frame, an entire prefab plumbing system, and so on, and build the skeleton of a house. Within that, you build a reasonably functional cabinet, though it's kind of hard to judge the cabinet among the entire rest of the incomplete house. How do you think that's going to compare to someone who just went and build a cabinet, and spent the time getting it built really nicely, paid attention to the detail work, made sure the door hung true and opened and closed without squeaks?

Here are a few things that I note at a cursory glance; and notice that I haven't even gotten to the logic of the code, because all of these things are red flags that come up before I am even able to read it:

1. Checking in dependencies to Git. That's not how it you do it; dependencies should be handled by a separate package manager, in which you depend on the appropriate versions of packages. You should never check anything other than your own source code into Git.

2. Your commit messages. Commit messages in Git should follow the format of an email describing a patch. The first line should summarize what the commit does; the rest of the commit should contain a description of why you are doing it. See the following for an explanation of what good commit messages should look like. First from the Git source itself:

http://git.kernel.org/cgit/git/git.git/tree/Documentation/Su...

And then a much more in depth guide:

https://wiki.openstack.org/wiki/GitCommitMessages#Informatio...

3. Inappropriate use of frameworks. You included a lot of dependencies that are unnecessary for the problem at hand. Dependencies have real costs; every extra dependency is something that could break, could have a security bug, could be a pain to upgrade in the future. Now, that doesn't mean to never add dependencies; but do so with a certain amount of care.

4. Simple spelling and style errors. Tabs vs. spaces. Inconsistent spacing: "var _createCell = function( color, id ) {" and "if ( el.className.indexOf('turned-over') > -1)" (note: decide whether there are spaces between parens and their contents, and stick to that choice). You spelled "RESTful" as "restFul". Things like this are seen by developers as canaries in the coal mine; if you are sloppy about the very basic stuff like tabs vs. spaces, are you really going to be mindful of other important things? Consistency of style is important for keeping code readable, if you can't even keep consistent in a simple code interview problem, why should anyone think that you'll be able to do it on a day to day basis when under real deadline pressure?

Here's my exercise for you. If you want to get better, and be able to pass future job interviews, condense this down into as small a codebase as you can, with as few dependencies as possible. I think that you should be able to do this in less than 100 lines of your own code, and only the most basic of dependencies like jQuery and some simple microframework on the server side.

Give that a shot, and then take a look at both for comparison. Which would you rather maintain? Which will be easier to make changes to? Which is easier to code review?

Re: Ask HN: What did I do so wrong in this coding interview

#65

Earlier quoted context omitted.

> 1. When your comments are longer than your code, either you're putting in too many comments, or your code is too hard to read. (The former seems to be the case here.) I hate this meme. There's nothing wrong with too much commentary. You are not on a comment budget. Please stop spreading this around, like the "rewriting is always a bad idea" meme that's embedded itself in young developers like dogma even though Spol…

I think you might've misunderstood what I'm saying. It's perfectly fine to have complex functions commented as much as necessary; heck, it's totally fine to have your comments be 100x as long your function when the function is actually hard to understand. What's not OK is commenting ALL of your code, especially not to such an extent where the comments are actually longer than the code size on average . (!) Some stuff…

I understand what you are saying perfectly, but you typed "you are putting in too many comments" as a possibility, full stop. All of that context you just painted for me is not in your comment. That's how "never rewrite because rewriting is bad because reasons" gets started.

And absolutely I think commenting all your code is okay. I honestly wish literate programming had caught on.

Re: Ask HN: What did I do so wrong in this coding interview

#66

You seem like a sharp developer who shouldn't be spending your time doing bogus homework in today's market. Out of curiosity, whereabouts are you located?

Exactly this. Might I suggest the next time a company asks you to do a project, tell them you don't work for free. It's tough sometimes because you really want the job, but in my experience, every single time I've broken my "not working for free" rule, I ended up doing work for a job I never got. What I'm trying to say is that there's a correlation between bad companies and tests like these.

For a quick project I think you did a great job, BTW, though there should never be any need for sudo. That was the only decent feedback honestfeedback provided. The rest is BS.

Re: Ask HN: What did I do so wrong in this coding interview

#67

Earlier quoted context omitted.

I think you might've misunderstood what I'm saying. It's perfectly fine to have complex functions commented as much as necessary; heck, it's totally fine to have your comments be 100x as long your function when the function is actually hard to understand. What's not OK is commenting ALL of your code, especially not to such an extent where the comments are actually longer than the code size on average . (!) Some stuff…

I understand what you are saying perfectly, but you typed "you are putting in too many comments" as a possibility, full stop. All of that context you just painted for me is not in your comment. That's how "never rewrite because rewriting is bad because reasons" gets started. And absolutely I think commenting all your code is okay. I honestly wish literate programming had caught on.

Well, quantity can be measured in different ways. I didn't say "your (individual) comments are too long"; I said "you have too many comments" (aka the total length of your comments is comparable to the total length of your code... i.e., your source files are on average more comments than code). Too many comments (even short ones) is generally bad; they make the code harder to read, not easier. A few long comments are generally good. I feel like you were addressing a different point than I was making.

Re: Ask HN: What did I do so wrong in this coding interview

#68

Earlier quoted context omitted.

I understand what you are saying perfectly, but you typed "you are putting in too many comments" as a possibility, full stop. All of that context you just painted for me is not in your comment. That's how "never rewrite because rewriting is bad because reasons" gets started. And absolutely I think commenting all your code is okay. I honestly wish literate programming had caught on.

Well, quantity can be measured in different ways. I didn't say "your (individual) comments are too long"; I said "you have too many comments" (aka the total length of your comments is comparable to the total length of your code... i.e., your source files are on average more comments than code). Too many comments (even short ones) is generally bad; they make the code harder to read, not easier. A few long comments are…

> Too many comments (even short ones) is generally bad;

That's exactly what I'm refuting, so I'm not sure why you keep talking past me. I am speaking to the crazy notion that there is a par for the comment golf course, and we all have to be Goldilocks as we write software. I don't know where that started, but I'd love it if people stopped judging software based upon the non-executable portions.

A line before every line? Maybe. Are they comments of quality? I've put a comment on every line of assembly before as a postfix. There is no hard and fast rule on this, and I wish people would stop trying to make one.

Again, literate programming. I feel like you're missing how serious I am about this by overlooking my repeated love for it.

Re: Ask HN: What did I do so wrong in this coding interview

#69

Earlier quoted context omitted.

Well, quantity can be measured in different ways. I didn't say "your (individual) comments are too long"; I said "you have too many comments" (aka the total length of your comments is comparable to the total length of your code... i.e., your source files are on average more comments than code). Too many comments (even short ones) is generally bad; they make the code harder to read, not easier. A few long comments are…

> Too many comments (even short ones) is generally bad; That's exactly what I'm refuting, so I'm not sure why you keep talking past me. I am speaking to the crazy notion that there is a par for the comment golf course, and we all have to be Goldilocks as we write software. I don't know where that started, but I'd love it if people stopped judging software based upon the non-executable portions. A line before every li…

Well in that case, there's nothing crazy about it. If I can hire someone whose code is reasonably self-explanatory vs. someone who puts comments all over their code (whether or not it's self-explanatory), I'm certainly not going to choose the second one over the first one, not sure about you.

Re: Ask HN: What did I do so wrong in this coding interview

#70

Earlier quoted context omitted.

> Too many comments (even short ones) is generally bad; That's exactly what I'm refuting, so I'm not sure why you keep talking past me. I am speaking to the crazy notion that there is a par for the comment golf course, and we all have to be Goldilocks as we write software. I don't know where that started, but I'd love it if people stopped judging software based upon the non-executable portions. A line before every li…

Well in that case, there's nothing crazy about it. If I can hire someone whose code is reasonably self-explanatory vs. someone who puts comments all over their code (whether or not it's self-explanatory), I'm certainly not going to choose the second one over the first one, not sure about you.

You just said if I took the same self-explanatory code and added comments to it that you deem unnecessary you'd no-hire me as a result. And yes, that is absolutely crazy, and has been my point throughout this entire thread.

Please do me the respect of researching literate programming before attempting to extend this thread, because I can tell you're unfamiliar, just based on how many ways you're trying to slice and dice a chink in my opinion on this.

Post reply on HN