skip to content

Where in a codebase would you allow the conversion to an unlabelled rectangle, and what would you require at that boundary?

level: principalimportance: should knowfreq 33%

answer

  1. late, narrow, one declared place
  2. an explicit field list at the seam
  3. the rectangle should not travel
  4. state the rule, do not leave it to habit
  5. numeric-first codebases invert the default

basics

~20 s

Convert late, narrow and in one declared place: at the edge of the routine that genuinely needs a positional rectangle, with an explicit ordered field list named there. Everything on either side of that seam stays named.

solid answer

~50 s

There is no universally right line, so this is worth stating as a rule and defending rather than leaving to habit. I would allow the conversion at a narrow seam — the routine that hands values to something which only accepts a rectangle — and forbid it mid-pipeline. Three requirements at that seam: the conversion takes an explicit ordered list of fields rather than the whole table, so a new field upstream cannot join by accident; the rectangle does not travel, but is consumed and turned back into named output in the same place; and if it must be returned, the ordered names go with it. The opposite default is right too, in a different codebase: where the bulk of the work is uniform numeric computation and names matter only at the edges, the rectangle is the natural primary holding and the labelled table is the adapter.

go deeper

for a junior

Recall the direction of the advice: keep names for as long as you can, and drop to a positional rectangle only where something actually requires one. Doing it early means everything afterwards depends on an ordering nobody wrote down.

for a middle

Be able to say what you would require at the seam — an explicit ordered field list rather than the whole table, and a rectangle that is consumed where it is made. Explain what each requirement prevents.

for a senior

Show that you would place the seam deliberately and defend the placement, including what it costs the people who have to follow it. A rule nobody can state the cost of tends not to survive its first deadline.

for a principal

Carry the judgment: name the property of a codebase that decides which holding is the default, describe the case where the opposite rule wins, and say what evidence would change your mind. The signal is a defensible position, not a preference.

## Why this deserves a rule rather than a habit Every crossing from a labelled table to a positional rectangle moves a contract out of the data and into the codebase's memory of a field ordering. Any one crossing is defensible. What is not defensible is having no position on where they are allowed, because the cost is not paid by the line that does the conversion. It is paid by whoever later adds a field upstream, or reorders a selection for readability, and gets arithmetic over the wrong pair of values with nothing raised anywhere. That is a standing cost, spread thin across a team and across time, which is exactly the shape of thing a lead is expected to own. ## A defensible default State it as: **convert late, convert narrow, convert in one declared place.** Concretely, three requirements at the seam: 1. **The conversion takes an explicit ordered list of fields**, never the whole table. A field added upstream then cannot join the rectangle by accident, and a reordering upstream cannot silently change what a given position means. 2. **The rectangle does not travel.** It is produced inside the routine that needs it and turned back into named output there. A positional holding passed across a module boundary hands an ordering contract to callers who never agreed to it and cannot see it. 3. **The ordering is recorded where the conversion happens.** If the rectangle must be returned at all, return the ordered field names alongside it so the receiver can check rather than assume. The rule costs a little ceremony at one seam. What it buys is that the number of places in the codebase where position carries meaning is a number somebody can state. ## The opposite default, and when it is right This is where the judgment actually lives, and a candidate who presents the rule above as universal has missed it. In a codebase whose bulk is uniform numeric computation — where names matter at the edges, when data is read in and when results are reported, and carry no weight in between — **the rectangle is the natural primary holding and the labelled table is the adapter.** Forcing every intermediate step through a labelled table there adds a second coordinate system nothing uses, and pays for names on values that are never looked up by name. | codebase shape | primary holding | where the conversion lives | | --- | --- | --- | | fields added, renamed and matched on throughout | the labelled table | one narrow seam, late, explicit field list | | uniform numeric work between a read and a report | the positional rectangle | at the two edges, named on the way in and out | | both, in different subsystems | whichever each subsystem is | at the subsystem boundary, ordering recorded | The rule is the same rule in all three rows: **there is one declared place where the two holdings meet, and it is written down.** What varies is which side is the default, and that is decided by how often the code refers to a value by name. ## What to argue about, and what not to - **Worth arguing:** whether a given subsystem is numeric enough to earn the rectangle as its default; whether a returned rectangle may cross a module boundary at all; whether the explicit field list belongs in code or in configuration. - **Not worth arguing:** whether the field ordering is "obviously stable". Nobody promised it, and treating it as a promise is precisely how the failure arrives. - **A trap:** banning the conversion outright. Code that genuinely needs a rectangle will convert anyway, in an unreviewed corner, without the field list — so the ban has produced the worst version of the thing it banned. - **A second trap:** allowing the conversion but keeping it early, at the top of a pipeline. Everything after it then works positionally, which is the maximal version of the cost with none of the benefit. ## Making the rule stick A rule that lives in a document is checked when somebody remembers it. A rule expressed as code is checked on every run. The cheapest version is a single named routine that takes a table and an ordered list of field names and returns the rectangle; everything else calls that, and the field list is then visible at every call site. It is not enforcement, but it turns "did they convert correctly?" from a question about discipline into one you can answer by reading the call sites. ## What an interviewer is listening for Not a rule. A rule **with its precondition**, an honest account of what it costs, and a case where the opposite rule is better. "It depends" with nothing after it fails the question; so does a universal ban. The signal is a candidate who can name which property of a codebase decides the default, say what the rule costs the people who follow it, and state what would change their mind.

  • When is the opposite default right — the rectangle first, the table only at the edges?
    When the bulk of the work is uniform numeric computation and names matter only where data is read in and where results are reported. There the labelled table is the adapter, and forcing every intermediate through it pays for a second coordinate system nothing in the middle uses.
  • How would you make the rule stick without relying on reviewers noticing?
    Express it as code: one named routine that takes a table plus an ordered field list and returns the rectangle, with everything else calling that. The field list then appears at every call site, so the question becomes something you can answer by reading call sites rather than by trusting discipline.
  • A team bans the conversion entirely. What goes wrong?
    Code that genuinely needs a positional rectangle converts anyway, in whatever corner escaped review, and without the explicit field list the rule was supposed to require. A ban removes the declared seam without removing the need, which is strictly worse than a rule that names where it may happen.

saying these in an interview costs you the question

  • Answers "it depends" with no rule and no deciding criteria.
  • Bans the conversion outright, leaving no path for code that needs one.
  • Converts once at the top and passes the rectangle through everything.
  • Relies on reviewers spotting an upstream field-order change by eye.
  • Treats the labelled table as the right default in every codebase.