Engineering Decisions Junior cheat sheet: interview answers
Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.
1. A server-rendered site lets guests pick a dark theme. The very first HTML must already use the right theme, with no flash. Where do you keep the choice?
Correct answer: In a cookie the server reads on each request
Only a cookie reaches the server with the request, so the HTML can be rendered in the right theme straight away.
localStoragefits client-only apps, or if a small inline script may set the theme before paint. A database table fits signed-in users who want the setting on every device, but guests have no account.2. A search box calls an API billed per request. Results should appear while the user types, but not on every keystroke. What fits?
Correct answer: Debounce: request after a short pause in typing
Debounce sends one request once typing pauses, so a burst of keystrokes costs a single call while results still appear without extra action. Throttle fits continuous streams like scroll or resize, where regular updates during the activity matter, but it would bill for half-typed words. Searching on Enter is the cheapest and fits expensive searches, but it breaks the requirement to show results while typing.
3. A popular blog gets its articles edited a few times a day. Search traffic matters, and text up to an hour old is fine. How do you render the pages?
Correct answer: Pre-render them and revalidate about hourly
Pre-rendering with periodic revalidation serves fast cached HTML to readers and crawlers, and an hour of staleness is allowed here. Per-request rendering fits personalized pages or data that must be current on every visit, and here it would only add load. Client-side rendering fits private dashboards, but it makes the first paint slower and is a poor match for pages that depend on search.
4. An online store's catalog has 10,000 products. Shoppers compare items, share links to a position and need the footer. How do you display the list?
Correct answer: Numbered pages with the page number in the URL
Numbered pages give each position a shareable URL and keep the footer reachable, which is what this catalog needs. Infinite scroll fits feeds that people browse without a goal, where a position doesn't matter. A virtualized list fits a data-heavy tool, where all rows are needed in the client, but downloading the whole catalog is wasteful here.
5. Two sibling components on one page share a filter value: one edits it, the other shows the filtered table. Nothing else needs it. Where does the state go?
Correct answer: In their closest common parent, passed via props
Lifting state to the closest common parent is enough for two siblings and keeps the data flow easy to follow. Context fits values needed by many components at different depths, such as a theme. A global store fits state shared across distant pages, and adding one for a single filter is more machinery than the task needs.
6. A badge shows unread notifications. They arrive a few times an hour, a one-minute delay is fine, and the hosting doesn't allow long-lived connections. What do you use?
Correct answer: Polling a small endpoint once a minute
With rare events, a tolerated delay and no long-lived connections, plain polling is simple and works on any hosting. A WebSocket fits two-way, low-latency features such as chat, but it needs infrastructure that keeps connections open. Server-Sent Events fit one-way live updates like scores, yet they also rely on a long-lived connection, which this hosting rules out.
7. Users upload avatars of up to 5 MB. The app runs on several instances behind a load balancer. Where do you store the files?
Correct answer: In object storage, keeping the URL in the database
Object storage is reachable from every instance, is cheap, and keeps files out of database backups. A local disk fits a single server, but behind a load balancer other instances wouldn't see the file. Binary columns fit a few small files that must stay transactional with their row, but avatars for many users would bloat the database and its backups.
8. Moderators delete comments, and sometimes must restore one within 30 days. Regular queries should stay simple. How do you implement deletion?
Correct answer: Set
deleted_at, and purge old rows on a scheduleA
deleted_atcolumn makes restoring a one-line update, and a scheduled job can purge rows after 30 days, as long as queries filter out deleted rows. Restoring from a backup fits disaster recovery, but it's slow and clumsy for one comment. An archive table fits data that is rarely restored and keeps the main table clean, at the cost of extra code for each restore.9. A big feature takes three weeks, while the team ships to production daily and conflicts are getting painful. How do you develop it?
Correct answer: Merge small parts to main behind a feature flag
Small merges behind a flag keep conflicts low while the unfinished work stays invisible to users. A long-lived branch fits a short task or a throwaway experiment, but over three weeks of daily releases it means a painful merge. A separate app fits a truly independent product, and for one feature it adds a deployment and duplicated setup.
10. Sign-up sends a welcome email through a provider that sometimes takes 10 seconds. Sign-up itself must stay fast, and the email may arrive a minute later. What do you do?
Correct answer: Put the email on a queue for a background worker
A queue returns the response at once, and a worker can retry if the provider fails, which suits a delay of a minute. Sending inside the request fits rare actions where the user must see the result of delivery, but here it ties sign-up speed to the provider. Sending from the browser exposes credentials and is lost if the tab closes, so it only fits a public, keyless client API.
11. A small team has one day to add tests before a launch. The checkout flow earns all the revenue and has never been covered. What do you write first?
Correct answer: A few end-to-end tests of the checkout path
A few end-to-end tests cover the whole money path in little time and catch the failures that hurt most. Unit tests fit complex logic such as price calculation, and they run fast, but they don't prove the pages work together. Snapshots fit stable output where any change matters, yet on a changing UI they mostly produce noise.
12. The product needs an accessible date picker next week. Nobody on the team has built one, and the app already uses a maintained component library. What do you pick?
Correct answer: The date picker from the existing library
A maintained component already handles keyboard use, focus and screen readers, which is weeks of hidden work. A custom picker fits a product whose core value is that widget and a team that can maintain it. The native input fits simple forms and is accessible by default, but its look can barely be restyled, so it fits only if the default appearance is acceptable.