INTERVIEWER: So, you may be able to guess, that there is a
problem with this code. It is very inefficient. If you
type a string with 30 characters into the text box, the
server gets called 30 times. Not good, we are having all
kinds of issues with scalability so we can’t afford to be
writing code like this.
Calling code 30 times is a problem. Sure there's a few places that might be true. Is this a device driver ? A video decoder maybe, or something else that's horribly complex ? Nope, just the most basic MVP website. Oh my fucking god. I remember programming on windows in Delphi, and on linux in QT. In both cases doing autocomplete the naive way just fucking works. Even with millions of possible completes.I remember implementing a function plotter that just completely refreshed a canvas pixel-by-pixel upon keydown. Not a problem. Even re-rendering a robot's simulated environment every keypress was nowhere near problematic.
And now we're worried about a 30 times called dead simple function, in the most basic of websites. Wow.
Progress.
(I understand why this happens. Server latency ... just works that way I guess. But I don't have to like it. HTML page layout is another peeve of mine. Resizable layouts are a solved problem in every single GUI toolkit except for one. Custom components are another seriously lacking web thing. It is a major javascript accomplishment to display a custom temperature-like gauge ... wtf ?)