4 ms·
Yeah, I think you can open your answer with, "well, I'd use libfoo, because there are a bunch of hairy edge cases", but then follow on immediately with a toy im
by jfb 13y ago
Yeah, I think you can open your answer with, "well, I'd use libfoo, because there are a bunch of hairy edge cases", but then follow on immediately with a toy implementation to show you understand the problem domain. There's a certain sort of nerd-arrogance to the "I'm too good to write it myself" sort of answer.
- michaelt 13y agoWhere you hear "I'm too good to write it myself" I hear "I'm too bad to write it myself" I mean, working on a whiteboard with no reference material and no test data I'd be glad if I had time in an interview to write a bug-free DOM parser that would work on a modern, standards-compliant web page - I wouldn't expect to even start on dealing with malformed inputs, javascript, images, nested documents...
- tptacek 13y agoSure. But writing a reliable bug-free DOM parser isn't the point of the question.
- michaelt 13y agoDo you mean you'd answer the question with a DOM parser that wasn't reliable and bug-free, that you wouldn't use a DOM parser at all, or that you'd use a DOM parser from a library (but consider such a library more acceptable than Calais which is understandable)? Seems to me you're going to have to get a handle on the page to figure out which entities are going to be treated as such and which are e.g. nested inside comments, or within javascript strings, or within inline CSS, or in the head, or after the body close tag, or resemble entities but aren't valid ones, and so on.
- wglb 13y agoThis is like in an interview context. The basic point to the question is at the highest level--how would you write such a parser, what might be some of the steps, what exactly is an entity. It seems like you are addressing a question of total implementation. But in an interview, I would expect a candidate to be able to answer--not fully implement--what some of the basic steps are. As opposed "use a library".
- jfb 13y agoMore to the point, if I'm asking you in an interview how to build a DOM parser, take it as given that, if you get the job, and we need a DOM parser, you will be actively encouraged to go use a library rather than build from scratch.
- wglb 13y agoAnd if I am asking you in an interview, it would be a given that you would be actively encouraged to figure out how to break it. One key skill in knowing how to break it knowing how one might be built. Learning how to think abstractly is one thing, but the ability to "puncture" abstractions is quite another. The latter is more valuable in this context.