Ask HN: I have 10 yrs of Exp. Failed 4 takehome projects. What am I doing wrong?
&gt;Is there a reason for this? I would think this was a good chance to show off your ability to write succinct&#x2F;standardized documentation w&#x2F; sections that anyone else would be glad to read&#x2F;see.<p>I threw the docs in the README for the submission, but for HN readers they want to see the problem first. The submission didn&#x27;t even include the specs.<p>&gt;Yeah I can see this, but I think &quot;automated tests&quot; are quite big in peoples&#x27; minds. Feels like it would be a checkbox on the item.<p>Yeah you&#x27;re completely right here. I&#x27;m gonna go with it next time.<p>&gt;I disagree here -- table stakes for a good API is integration and E2E testing -- and they&#x27;re the easiest to do (no need to manipulate a browser window, etc).<p>Yeah but many companies don&#x27;t do integration testing as the infra on this is huge and writing tests is more complicated. It&#x27;s certainly overkill for take home. I would say you&#x27;re wrong here. Completely. This company was not expecting integration tests as part of the project at all.<p>I&#x27;ve worked for start ups most of my career, and I&#x27;m applying to start ups. It&#x27;s mostly the huge companies that have the resources to spend the effort to have full coverage on that.<p>Integration tests are Not easy, btw. Infrastructure is not easy to emulate completely, how would I emulate google big query or say aws iot on my local machine? Can&#x27;t, most likely integration tests involve actual infra, combined with meta code that manipulates docker containers.<p>&gt;Sorry INPUT is what I meant to write there -- what happens if you get a -1 ?<p>You get a 500. Which is not bad. But you&#x27;re right a 400 is better here.<p>&gt;Right, but this is what I mean -- when I read that I wondered if it was complete, and it wasn&#x27;t. That&#x27;s an unnecessary ding to take.<p>I feel this is such a minor thing. I&#x27;m sure most people would agree if you dinged that you&#x27;d be the one going overboard, not the candidate.<p>&gt;This is going to build objects dynamically every execution right? That&#x27;s what I thought could be avoided. Less about lists vs generators, more about doing things that look like they allocate so much.<p>You&#x27;re going to build objects dynamically every execution Anyway. This saves you the extra intermediary step of not having to save it to an extra list.<p><pre><code>    numbers = [i*2 for i in range(500)] #allocated list in memory: 500*sizeof(int) (big) 
    for i in numbers:
       print(i + 1)

    numbers = (i*2 for i in range(500)) #allocated generator in memory: sizeof(*generator) (small)  
    for i in numbers:
       print(i + 1)
</code></pre>
Look at the above. Same concept. Generators are drop in replacements for actual state. State and functions are the isomorphic (ie the same thing). Building a generator is cheaper then building a list. You should read SICP about this topic of how functions and data are the same.<p>&gt;Ah OK, but this isn&#x27;t what they asked for, right? If we want to be really pedantic, your endpoint returns a 3xx for every single error.<p>It&#x27;s a reasonable assumption that all users assume &#x2F;xx&#x2F;xx equals &#x2F;xx&#x2F;xx&#x2F;. It&#x27;s also reasonable for a client to handle a 302 redirect. The specs didn&#x27;t specify the exact definition on either of these things.<p>&gt;The measurement endpoint will be called far more (100x, 1000x, ...) than the stats endpoint -- it&#x27;s the hot path.<p>So? logN is super fast. You have 100 objects binary or whatever indexed insert redis uses gets there in at most 4 or 5 jumps. So even if it&#x27;s the hot path redis can take it.<p>NLogN is slow enough that if N is large there is noticeable slow downs EVEN when it&#x27;s a single call. Recall that redis is single threaded sync. NlogN can block it completely.<p>Either way this is all opinion here right? Ideally the results are returned unsorted. the client is the best place to sort this, but that&#x27;s not the requirement.<p>&gt;Also, note that sorting is zero cost, but retrieving the data will still be in N time including network round trips, which will likely dwarf any time you spend sorting in local memory. Even the conversion to JSON will dwarf the time you spend sorting for large N.<p>Of course the act of reading and writing data will cost N regardless. But your reasoning is incorrect. Look at that picture again: <a href="https:&#x2F;&#x2F;i.stack.imgur.com&#x2F;osGBT.jpg" rel="nofollow noreferrer">https:&#x2F;&#x2F;i.stack.imgur.com&#x2F;osGBT.jpg</a>. O(NlogN) will dwarf O(N) when N is large enough. It will even dwarf IO round trip time and has the potential of blocking redis completely on processing the sort.<p>&gt;Also, the point of memory usage being potentially large is still relevant. My instinct is that when I see something returning a possibly very large piece of data, setting up for streaming is the way to go. Doing a scan you have the possibility to use far less memory for an individual request, and you could actually stream responses back in extreme cases, so you can avoid holding the entire result set in memory at all.<p>Sure but look at the specs. It&#x27;s asking for http requests. It&#x27;s not a streaming protocol here. I mean at this point if you were evaluating my code for a job you&#x27;d be going to far already as your going off the rails completely.<p>&gt;The point about error handling still stands with respect to reporting though -- you generally want to see error handling in code, rather than just leaving it up to the runtime to fail the task and carry on.<p>I mean I could build a full logger and error handler framework here. I&#x27;d put custom handling in a decorator and have the error handling invisible in the http route handlers. Flask already does this, but it just returns 500 on all exceptions. That is the most elegant way imo. But again this is a bit outside of the scope of a takehome, given the framework handles a lot it and the extra effort required.<p>&gt;If you want to get really fancy, you can get creative with how data is stored on the redis side and get the size to N.<p>For takehomes and in general people prefer readable code. Only optimize if it&#x27;s needed. I mean I can write the whole thing in assembly code for ultimate performance. I can def see some nitpicker dinging me for optimized but unreadable code.<p>&gt;The things you include&#x2F;don&#x27;t include by instinct I think is valuable signal.<p>Not to be insulting here. But I think your instincts are pretty off here. There&#x27;s a limited amount of time assigned to this project. All the basics were included with what I did in the time allotted.<p>When you have good instincts you know when to apply automated testing, when to use error handling. These aren&#x27;t things you should do all the time. Your attitude is something I see in many younger engineers. This attitude of rule following and best practices is just adhered to without thinking it all through properly. For the scope of the project. most of what you wrote here isn&#x27;t needed.<p>You&#x27;re also not testing what&#x27;s traditionally tested in interviews. They test intelligence, depth knowledge and ability to design and solve problems. You&#x27;re testing the ability to follow written rules. I mean following these things is trivial. It doesn&#x27;t take much brain power to write error handling or unit tests. Perhaps you&#x27;re just testing for someone that agrees with your programming philosophy. I mean these things can be followed regardless<p>Your mention of integration tests is telling. I mean the code for integration tests can rival the size of the code in the project itself with the a minor benefit in safety . It&#x27;s not just take home assignments but many many many companies loaded with senior engineers skip over automated integration tests and keep those tasks in todo lists for the longest time. There&#x27;s a huge engineering cost to building out testing infra to the maximum ideal, and many companies just don&#x27;t bother. It&#x27;s mostly the bigger well established companies that have the resources to do this.<p>&gt;I&#x27;d disagree that it&#x27;s worse than algo interviews, because algos are rarely the most important thing in a professional code base, especially one with that&#x27;s about web services and not something more demanding.<p>It is worse in my opinion because it&#x27;s biased. What if your opinion was more correct then my opinion but I judged you based off of my world view? Would that be right? No it wouldn&#x27;t. Programmers are diverse and the best organizations have diversity in opinions and expertise.<p>All in all I mostly disagree but I think your right on one thing: At least one of those job candidate evaluators that are looking at my code likely had a similar attitude as you do and I should bias my code towards that more. Likely won&#x27;t write integration tests though, hard no on that one.<p>Also good catch on the &#x2F;test&#x2F;-1&#x2F;. That&#x27;s definitely a legit ding imo.