11 ms·
Some time ago, I was contacted by Apple to apply for a job. My code is insanely well-documented. I like to think that a lot of the inspiration for my code docs
by ChrisMarshallNY 7y ago
Some time ago, I was contacted by Apple to apply for a job.
My code is insanely well-documented. I like to think that a lot of the inspiration for my code docs comes from Apple's open codebases. Their code is exceptionally well-documented.
In any case, as is usual with all employers, these days, they completely ignored the focused, relevant links that I sent them to elements of my extensive portfolio of repos, and, instead, based the entire interview on a 50-line binary tree test in Swift.
I'll make it clear that I'm NOT a fan of these. I am mediocre, at best, at them, as I don't come from a traditional CS background (I started as an EE).
In any case, during the test, I did what I always do when I write code. I stopped to write a header document for the function.
This was clearly not something the tester liked. Also, to add insult to injury, they dinged me for not writing a cascaded nil-coalescing operator. The code they wanted me to write was difficult to understand, and absolutely not one bit faster.
What makes this even funnier, was that this was for an Objective-C job, and the links that I sent them (that they ignored), were to ObjC repos.
After that, I just gave up on them. It kind of shows where a lot of this is coming from.
Dynamically-generated documentation can be great (It's clear that the lions' share of Apple's developer documentation is dynamically-generated), but it requires a VERY disciplined coding approach. I suspect that they may be hiring less-disciplined engineers, these days.
- jtchang 7y agoWhat is a "cascaded nil-coalescing operator" ?
- omaranto 7y agoSomething like a.?b.?c which is syntactic sugar for: a && a.b && a.b.c (with a short-circuiting &&.)
- rimliu 7y agoThis is just optionals chaining, not nil coalescing.
- omaranto 7y agoThanks for correcting me, I actually wasn't aware of nil coalescing in Swift and guessed it meant the same thing as optional chaining. The nil coalescing operator seems to correspond to Haskell maybe function, that is, a ?? b is computed as follows: if a is nil, the result is b; otherwise a must wrap some actual value c and the result is c. Is that the one you had in mind?
- dtech 7y agoThis is Javascript/Typescript only, and not really correct. a?.b a && a.b will behave differently if a is false or 0 or an otherwise "falsy" value. It's identical to something similar though (a !== undefined && a !== null) ? a : b
- omaranto 7y agoThat's right, of course. I was just trying to convey the idea. But details matter of course. I was thinking of variables that either contained nil or contained an object with the appropriate field. If that precondition isn't meant you need more robust code like yours. But also, as another commenter pointed out, there is a distinction between "optional chaining" and "nil coalescing" and I explained (roughly) what optional chaining is.
- amflare 7y agoWell a nil-coalescing operator is: a ?? b Where this is shorthand for: a != nil ? a! : b idk what cascaded means, but it sounds like a ternary operation from hell.
- ChrisMarshallNY 7y agoThink the ternary operator, but worse. In Swift, this is expressed by "??". It means "If the previous test returns nil, then execute what is after the ??". For example, if you have a concrete Int, but the source might be an optional, then you could do something like this: let a = b ?? 0 That means that if b is nil, then set a to 0. Otherwise, set it to whatever value b has. You can chain these, like so: let b: Int? = <something from somewhere> let c: Int? = <something from somewhere> let a: Int = b ?? c ?? 0 So you have a couple of optional values coming in, but they could be nil, so you chain them. You can have a lot more going on in the handlers than simple assignments, but this gives you an idea.
- accatyyc 7y agoIn Objective-C (and some other languages with ternary operators) the same can be written like this: int a = b ?: c ?: 0
- ChrisMarshallNY 7y agoYup. Personally, I like the ternary operator, and I also like the nil-coalescing operator, but I'm quite aware that they can produce difficult-to-maintain code, so I'm careful with them. I have gone and done some silly stuff with both, but then, I realized that I was leaving unmaintainable code. If you use godbolt.org, you can actually see what code is produced by the source.
- messe 7y agoThe second conditional is unneeded as the 0 will only be returned if c evaluates to 0, so it can equally well be written int a = b ?: c;
- WWLink 7y agoThat one's straight up called the Elvis Operator. I hate it when things like this get names that everyone's supposed to know and it's considered a mark against you if you've never heard it before, but I do think the name Elvis Operator is hilarious. :D
- AgloeDreams 7y agoI'm not sure how it looks in ObjC but in Typescript you could write something like: let studentScoreFormatted: string = student.formattedScore ?? 'Student has not taken this test yet.'; Whereas if the score is null it will return the value after `??`. It is awfully helpful for ensuring you handle error states in displaying API values. Additionally if you want this behavior but when the value is falsey, then you can use `||` instead.
- jamil7 7y agoDo you mean Swift? I didn't think Typescript had something like this yet.
- h0h0h0h0111 7y agoNot sure about OP, but this is coming in Typescript 3.7 I believe. Currently you can use `||`, but as mentioned above it will also catch false, 0, "", etc
- AgloeDreams 7y agoBingo. TS 3.7
- leshow 7y ago?? doesn't exist in typescript yet, but there is a tc39 proposal to add it to js proper
- AgloeDreams 7y agoTS 3.7 adds it.
- rimliu 7y agoA bunch of double question marks with some optionals in between would be my guess. optional1 ?? optional2 ?? optional3 ?? ifeverythingelsefailsvalue
- whatshisface 7y agoIt's Swift's equivalent of Rust's `unwrap_or`, or the trick in python where you write `None or "Hi!" == "Hi!"`.
- JKCalhoun 7y agoSomeone that works in a Matryoshka doll factory? Just a guess. I'm not a CS major either.
- pmhpereira 7y agoa = b ?: c; if b is not nil, then a = b else a = c
- emilfihlman 7y agoApparently it functions a bit similar to the javascript || assignment. https://stackoverflow.com/questions/2100758/javascript-or-variable-assignment-explanation https://stackoverflow.com/questions/2100758/javascript-or-va...
- mattz0rt 7y agoPython equivalent: return a or b
- GGfpc 7y agoTo be honest, while documentation is extremely important in the real world, interviews are time-constrained, and it makes no sense to write documentation when you have 45 minutes to implement something like that.
- Yhippa 7y agoI'm not defending those types of interviews, because I'm not great at them, but it seems that they're looking for human algorithm machines. People who can go in and write very specific performant code. Maybe that's the requirement for the job as opposed to someone who can interface with businesses and do general enterprise software.
- sdegutis 7y agoI have personally found that sometimes writing out comments that explain how a confusing function is going to work will help me to understand the ins and outs and flow of the function before writing it, which will in turn help me to actually write the function, especially with algorithmic functions. Those comments might as well be written as long-standing documentation that doesn't change as long as the implementation/algorithm doesn't change. I know "comments lie" but if it's a long-lived implementation, it's more beneficial than not.
- jniedrauer 7y agoWriting a function docstring is just muscle memory for me. It's part of my process. Explain the objective, then implement it. Docstrings are usually the first or second thing I write after the function signature. I would also have serious reservations about taking a job where documentation is considered a negative during a coding interview.
- xahrepap 7y agoI disagree. It's one way for the interviewee to reiterate back to the interviewer that they understand the problem and constraints.
- ChrisMarshallNY 7y ago
- ensiferum 7y agoMost interviewers don't give a crap about one's GitHub/Bitbucket/X portfolio. It might help one to get the interview in the first place but after that point it's useless. Why? Because any single interviewer has a set of well rehearsed questions they know like the back of their hands. They know the different possible solutions and understand their pros and cons. This makes the interviewing a routine that lessens the brain drag. I in an interview setting you wan't to know your shit. Using the candidates online source code repo portfolio would mean that the interviewee would have to try to understand the candidate's code and whether it'd be applicable to the intended role and how well the code would lend itself as a measuring stick for the candidate's skills. This is a lot more work and so obv it won't be done.
- mmahemoff 7y agoAsking the same questions also makes it easier to compare between candidates and the questions can become optimised over time to ensure they are fair and valid performance predictors. Also, it's never obvious how much someone contributed to their portfolio. Just being able to explain it doesn't mean you were the sole contributor, or the contributor at all, and it doesn't give a great indication of how you work or how well you can analyse problems.
- ensiferum 7y agoYep, exactly.
- ChrisMarshallNY 7y ago"Also, it's never obvious how much someone contributed to their portfolio." You guys are absolutely correct about the reference questions. I can find no fault with that. However, there's absolutely no question that I'm the sole contributor to all my code. Most of my repos have only one contributor (Yours Troolie). A couple have been forked off. I do link to a number that have been turned into larger projects; with multiple contributors, but there's no question that's happened. Also, those are my old PHP repos; not the ObjC or Swift ones. There's ten years of commit history in the repos. You could run crunchers on them to do things like develop velocity and productivity metrics. I'm also quite aware that my case is unusual. Most folks don't have such extensive portfolios, and are much more of a "black box."
- SkyPuncher 7y ago> I'll make it clear that I'm NOT a fan of these. I am mediocre, at best, at them, as I don't come from a traditional CS background (I started as an EE). I come from a CS background and struggle with these too. The big problem I have is this performance stuff is often barely relevant to the position. You need to know the principle of a BST. Unless you're building a database working in a unique scenario, actually traversing it going to be done by some library.
- ben_jones 7y agoI wonder if the merit of these exercises is from reading the candidate's reaction to meaningless and trivial tasks. If they take it with a smile, or better yet if they spent part of their free time studying it in detail, they will make a terrific cog in the machine...
- govg 7y agoTo be honest, as a part of hiring procedure, it has its merits. In an ideal world, you want to ask the candidates a problem that is well defined, and applies the tools that they might have learned in their past. This is why algorithmic problems are common - a large pool of candidates have recently finished school, they have a lot of fundamental knowledge from their experience there (and nothing else), and asking these is a way to evaluate [ how well is this problem approached ] with [ tools they should have at their disposal]. It's more about can you understand what you have learnt and use it to solve a novel thing, and less about can you balance a binary tree given 100 integer inputs. It's largely devolved in a cat and mouse game now, with candidates spending a large part of their time poring over CLRS or on Leetcode, and companies asking increasingly difficult (and serving no purpose but testing how much time was spent on practising) whiteboard questions.
- jschwartzi 7y agoWhere this falls down is when you're hiring someone who has 10 or 15 years of experience and has forgotten more about day-to-day product development than the freshers have learned about algorithms. So you're asking that guy questions that the freshers have fresh in their minds because it's all they know, and it's totally unsurprising that he fails because he hasn't ever used that knowledge in a work setting. You do need to tailor your interviews to the person's experience level. If you're hiring for experience, ask that person about process and about team forming and about mentoring and leadership. You don't have to be able to write a perfect algorithm as a senior, only to help your juniors over the hurdles keeping them from doing it themselves.
- skybrian 7y agoIt sounds like you might not be quite getting the concept behind this sort of interview. Although some code is written, this is (usually) a test of how you talk about code. You want to show that, if a co-worker asks for your advice on how to solve a tricky problem, you will be able to help them figure it out. Part of this is understanding what they're asking for and adapting. If someone wants to know how to document code properly then you can have a conversation about that and give an example. But if they're asking about algorithms then you write the code and explain how it works verbally. You don't need to write comments because the reader is right there and you can explain it to them. It's not production code.
- EpicEng 7y ago>It sounds like you might not be quite getting the concept behind this sort of interview. Although some code is written, this is (usually) a test of how you talk about code. Assuming everything the GP said is true, what you're saying is completely contradicted by the fact that they were dinged for not using a null coalescing operator.
- mypalmike 7y agoWhy not both. They want to hear you talk through the solution. And they have unhelpful biases about what they want to see in the solution.
- EpicEng 7y agoWell... sure, why not? I was responding to this though >It sounds like you might not be quite getting the concept behind this sort of interview. Although some code is written, this is (usually) a test of how you talk about code. You want to show that, if a co-worker asks for your advice on how to solve a tricky problem, you will be able to help them figure it out.
- skybrian 7y agoWell, yeah. But it may be that, when talking to a co-worker about something, they point out some programming syntax you weren't aware of, just as a way of trying to be helpful. What's a good way to handle it? You could thank them for pointing it out, say you're not sure you want to use it (if you don't think it's better) and then get the conversation back on track. And, hopefully they'll think you handled it smoothly and won't take off points, but you'll never know how important it is to them that you're fluent in Swift. Maybe not at all, it's just an aside? Which is to say, usually you can't tell in an interview what they're really grading you on. It's nerve-racking, but you just have to try to seem reasonable and hope that works.
- phendrenad2 7y agoI used to think Google and Apple were making a poor choice by doing this kind of interview, but I wonder now if it gets the results they want: they want interchangeable cogs that don't stand out too much. They want known quantities. If you're "the documentation guy" or "the security-testing girl", you've wasted time learning skills they won't utilize, since they want you to be exactly like every other developer. If documentation and security are going to happen at the company, a dedicated team will be formed for that, with monthly reports on key metrics going up the chain to management. That's how big corporations work, from what I've seen.
- blueblisters 7y agoYeah I have come to a similar conclusion - the labor marker for software developers in the bay area in a sense becomes highly liquid because of similar job requirements, experiences and interviews. Heck I was told by a FB interview to basically go through leetcode “hard” problems to prepare for the interview.
- moftz 7y agoHR wants the cogs that are flexible because they can cram them somewhere whenever the company wants spin down a team and move the personnel elsewhere. This is great for big companies that just need warm bodies to crank out crap however it's an inefficient process when you look at the lower level. You have a larger team of people that are less familiar with the task that a smaller team of experts could handle better and faster. If you can handle the schedule and direct cost hit of a larger, less specialized team, it reduces the later costs of needing to lay off people and hire new people. You can just move these warm bodies around somewhere else. A small specialized team is going to be a bit more riskier since once the job is done, are you going to have a need for these experts? Would they want to stick around doing something they never wanted to do? If a specific field is your core business, hiring experts is critical when starting up. But once youre a massive corp, you really just need boots on the ground to handle the mundane. College fresh-outs are usually the kinds of people that get drawn into these warm body kinds of jobs. They want blank slates that can crank out code, documentation, or whatever the pointy hairs need. If you really do consider yourself an expert, consider a consulting/contractor gig where you come in, do the specific job they really need, and leave with a bucket of cash.
- arcticbull 7y agoRealistically only the recruiters looked at the repos/portfolio you provided, if at all -- that's to get you through the door. Once you get on-site interviewers tend not to even look at your resume. This can be good or bad, as it eliminates a lot of bias based on education, background, etc. An interviewer has a question that's well calibrated, that they've seen people answer hundreds of times. There's a simple answer, a better answer and an "if you can teach me something I'll just hire you" answer. If you spend time doing extraneous things like documentation during a coding challenge you likely won't do well, not because documentation isn't valued but rather because you won't have time to move from the "simplest" answer to the "best" answer, let alone the "teach me something" answer. This may frustrate your interviewers because they're seeing you spend your time in a way that's not advantageous to you. They may even be more frustrated if they actually liked you as a candidate. Tests are different because they often help you move more quickly and confidently between layers of the question as you can sanity check you revised implementation against your tests.
- microtherion 7y agoSpeaking only for myself, before I interview someone, I definitely look at their resume and prepare a few questions about it. I also look at github accounts if they were mentioned in the resume, but I tend to downweight them for a number of reasons: 1) You can't always be 100% sure the code was actually written by the candidate. 2) One quality I'm looking for in particular is somebody who can work well with OTHER PEOPLE'S CODE, and that's even harder to evaluate. If I see a balance of original repos and forks, that might be some evidence, but again, how do I dig out what they contributed? Chasing down PRs would be more helpful, but that definitely is too much work for a job interview. 3) Having a busy github account could be a marker of particular life circumstances (to avoid waving the red flag of "privilege" around too much) — the candidate is not overly busy working a second job, raising young children, or giving 120% in his day job. 4) There are plenty of respectable reasons not to code in your spare time — you may have different hobbies etc. When hiring pathologists, we don't give preference to candidates who cut up bodies in their spare time. We should get out of the habit of doing so for programmers. 5) A busy github account can also be a warning sign of somebody who might be more invested in side projects (or possibly even bootstrapping a startup) than in their day job.
- kevingadd 7y agoGoogle is all-in on this too, but in my experience Apple is way worse at that kind of interview just like you experienced. I had one interviewer ask me to write strstr but then insist that boyer-moore could not possibly work. I don't expect every engineer to be familiar with common CS algorithms but whew, if you're gonna use them as an interview question... The other parts of the interview weren't as bad but they also weren't great. Expecting you to know what happens when you export an int as 'main' instead of a function, for example - you can certainly figure that out from first principles or happen to know, but why should you? It's sort of a "when a company shows you who they are, believe them" situation - even when I did get offers, seeing this reduced my confidence in the company.
- twblalock 7y ago> This was clearly not something the tester liked. Also, to add insult to injury, they dinged me for not writing a cascaded nil-coalescing operator. The code they wanted me to write was difficult to understand, and absolutely not one bit faster. The interviewer probably wanted you to write idiomatic Swift. That seems reasonable.
- ChrisMarshallNY 7y ago..except that it was for an Objective-C position, and "idiomatic Swift" doesn't mean "unmaintainable Swift." Most of the open-source code that I've written has been for other people to take over. Most of my repos are still 1-contributor ones, but every single one has been written to be extended. The ones that have been extended are being extended very well, indeed. I have had almost zero questions about the codebase.
- cabaalis 7y ago> not writing a cascaded nil-coalescing operator Given that a large portion of the discussion in this thread is around what this operator is, it seems somewhat valid for a company to want to see you use this. It might represent a deeper experience in the language being used, or at least some previous study of syntactic options.
- derefr 7y ago> I suspect that they may be hiring less-disciplined engineers, these days. I don't know about that; if Apple had lowered their hiring bar, they'd likely have enough engineers to not be constantly starving one project or another of talent because it's being "borrowed" by the Big New (next-to-announce-at-a-keynote) Thing. That still seems to be a problem; I haven't noticed any decrease in the number of Apple projects that "lay fallow" while their engineers are off doing something else.