Job search
An Employer Requests a Code Sample: Choose a Small Example and Explain the Trade-Offs
A filled selection record and an actually executed original Python package demonstrate a small code handoff, with assistance provenance, meaningful tests and explicit limits.
When an employer requests a code sample, choose an example whose purpose, contribution and important decisions can be understood without exploring your entire account. Read the request first: it may ask for existing work, a particular language, a short excerpt or a runnable project. A reviewer still needs the requested sample, even when your repository homepage is polished.
LandOffer publishes this guide and offers job-search tools; compare relevant roles on LandOffer.ai and keep each employer’s sample instructions with the application. This guide supplies a completed selection record and a small original code package. An AI assistant authored and reviewed the package and executed it locally; no human implementation or review was observed. The sample requests below are invented, not instructions from a real employer.

Extract the request before choosing the example
Record the permitted language, scope, delivery format, dependencies, deadline and assistance rules beside the request. Separate an existing-code request from a new assessment. Permission to show a personal project does not authorize AI assistance in an assessment, and a general invitation to share work does not authorize disclosure of former-employer code.
If a request says “small example,” do not silently decide that it means one file, a particular line count or a public GitHub repository. A short function might need its tests and contract; a larger application might need a clearly marked entry point. Follow the specific request, including whether a link, attachment or private access is permitted. This guide sends nothing and creates no repository.
Drew Hoover’s Atomic Object article, dated April 10, 2016, describes his hiring-review preferences: a focused problem, useful context, good practices and an explanation. It mentions roughly 20–100 lines as a preference and explicitly calls its advice a rough guide. That is a dated practitioner account, not a current rule for all employers or confirmation of Atomic Object’s present requirements.
Completed selection record: one fit and one honest hold
The first completed asset compares three candidate materials against two fictional requests. Request A asks for a small Python example with tests and a short explanation; the invented instructions explicitly allow disclosed AI assistance. Request B asks for a personally implemented interactive frontend component. Neither request supplies a real deadline, employer identity or delivery channel.
| Material considered | Request A decision | Request B decision | Reason and boundary |
|---|---|---|---|
| Former-employer service excerpt, permission unknown | Withhold | Withhold | Changing names would not establish permission; no real proprietary code was accessed for this example |
| Tutorial clone with little independent change | Do not choose as the primary sample | Do not choose as the primary sample | Attribution alone would not explain independent engineering decisions or satisfy the stipulated personal-implementation request |
| OutlineOrder, the new assistant-authored local Python package below | Select as a disclosed teaching example under Request A’s invented assistance rule | Reject for this request | It demonstrates a Python contract and checks, but supplies neither a frontend component nor observed personal human implementation |
The completed Request A decision reads: “Use the small chapter-ordering package with its README, fixture, tests and assistance statement. Identify the exact source version and explain that the assistant created and reviewed it. Do not claim it was a candidate’s prior employment work or that a human personally wrote the implementation.”
The independent Request B decision is hold: “No eligible frontend sample is established in this record. Do not relabel the Python package or hide its provenance. Prepare an appropriate original component under the genuine rules, or ask whether an alternative is allowed before choosing a submission.” This is a completed selection outcome, not a claim that another component has been built.
Use the genuine request and work you can explain and share. Tests cannot establish disclosure rights or turn generated code into personally implemented experience.
Define a small contract that can be reviewed
The second asset is OutlineOrder, a local Python example for arranging sections in a small document pack. Each record has an id and a needs list naming sections that must come first. The output is an ordering of those identifiers. It does not write documents, launch commands, install dependencies or execute a workflow.
The sample accepts a parsed list of at most 50 section records. Identifiers are nonempty, case-sensitive strings without leading or trailing whitespace. Each record must contain exactly id and needs. Duplicate section identifiers, repeated dependency identifiers and unknown dependencies are rejected. An empty list produces an empty order.
When several sections are ready, it chooses the lexicographically smallest identifier, then inspects the remaining sections again. This gives a deterministic tie rule rather than depending on input order. It also makes the implementation easy to follow at this deliberately small scope. The algorithm repeatedly scans remaining sections and dependency sets; no large-graph performance claim was tested.
A cycle prevents a complete order. The error lists unresolved sections, which can include nodes downstream of the cycle. It does not pretend to identify the exact cycle or propose a repair. A reviewer can therefore question unresolved nodes without mistaking them for an extracted cycle path.
Run the example and inspect the result
The implementation is 59 lines including comments and blank lines, separate from tests and documentation. Its size is an observation, not a target derived from the 2016 article. It uses only Python’s standard library; the actual local execution used Python 3.12.14, without installing dependencies.
The complete implementation is below; the accompanying tests and saved results are described afterward.
"""Order a small synthetic document pack; never execute tasks or commands."""
import json
import sys
class OutlineError(ValueError):
pass
def order_sections(records):
"""Return lexicographically stable dependency order, at most 50 sections."""
if not isinstance(records, list) or len(records) > 50:
raise OutlineError('expected a list of at most 50 sections')
dependencies = {}
for record in records:
if not isinstance(record, dict) or set(record) != {'id', 'needs'}:
raise OutlineError('each section requires exactly id and needs')
name, needs = record['id'], record['needs']
if not isinstance(name, str) or not name.strip() or name != name.strip():
raise OutlineError('id must be a nonempty, unpadded string')
if name in dependencies:
raise OutlineError('duplicate id: ' + name)
if not isinstance(needs, list) or any(not isinstance(n, str) for n in needs):
raise OutlineError('needs must be a list of section ids')
if len(set(needs)) != len(needs):
raise OutlineError('duplicate dependency for: ' + name)
dependencies[name] = set(needs)
unknown = sorted(set().union(*dependencies.values()) - dependencies.keys()) if dependencies else []
if unknown:
raise OutlineError('unknown dependencies: ' + ', '.join(unknown))
remaining, completed, result = set(dependencies), set(), []
while remaining:
ready = sorted(n for n in remaining if dependencies[n] <= completed)
if not ready:
raise OutlineError('unresolved sections: ' + ', '.join(sorted(remaining)))
chosen = ready[0]
result.append(chosen)
completed.add(chosen)
remaining.remove(chosen)
return result
def main(argv):
if len(argv) != 2:
print('usage: outline_order.py INPUT.json', file=sys.stderr)
return 2
try:
with open(argv[1], encoding='utf-8') as stream:
records = json.load(stream)
result = order_sections(records)
except (OSError, UnicodeError, json.JSONDecodeError, OutlineError) as error:
print(json.dumps({'error': str(error)}), file=sys.stderr)
return 2
print(json.dumps({'order': result}, ensure_ascii=False))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
The owned fixture contains four sections in deliberately mixed input order: proof needs draft, bundle needs proof and assets, and the other two have no prerequisites. The first run command, from inside the sample directory, is:
python3 outline_order.py example.json
The actual saved standard output is:
{"order": ["assets", "draft", "proof", "bundle"]}
assets and draft are initially ready, so the tie rule puts assets first. After draft, proof becomes ready; bundle follows both prerequisites. The function builds its own dependency sets and result list rather than editing the caller’s records. The tests check that the fixture remains unchanged and that reversing its input list gives the same result.
The entry point reads one local UTF-8 JSON file, reports a JSON error on standard error for handled failures and returns exit code 2. A malformed fixture was actually run: it returned 2, produced no success output and supplied an error record. The success fixture returned 0. These saved CLI results establish local execution only; no employer or human reviewer ran the package in this session.

Explain the tests instead of advertising a green badge
Python’s unittest documentation describes test cases and a runner that collects their results. Our test file uses those standard facilities. The actual local run passed 12 named test methods; some contain several input checks. Twelve counts named methods, not all possible inputs, a coverage percentage or production readiness.
| Executed check | Expected behavior and actual result | Why it belongs in this sample |
|---|---|---|
| Empty list and diamond dependency | Empty order; diamond returns A, B, C, D | Checks valid boundaries and a shared prerequisite |
| Ready-item tie, reversed input and original input | Stable fixture order; original records unchanged | Makes determinism and mutation policy inspectable |
| Unknown prerequisite, duplicate identifier and repeated edge | Each raises the stated input error | Prevents silently inventing or collapsing ambiguous sections |
| Self-cycle and two-node cycle with downstream C | Errors; second reports A, B and C as unresolved | Demonstrates that unresolved nodes are not necessarily all cycle members |
| Schema/type cases and 50/51 boundary | Invalid shapes rejected; 50 accepted and 51 rejected | Exercises the stated parsed-record contract |
| CLI success and malformed JSON | Exit 0 with order; exit 2 with error and no success output | Checks the handoff entry point, not only an imported function |
A separate verification script does not import the implementation. It reads the saved four-section fixture and result, checks the literal expected order, confirms every identifier appears once and checks prerequisites against their positions. Three in-memory bad results—missing a section, duplicating one and placing proof before draft—were rejected. The original saved output was unchanged.
That second script is still assistant-authored review of one fixture, not independent human review or a general proof of the algorithm. The tests do not establish performance on large inputs, all Unicode behaviors, a production scheduler or security under hostile input. The implementation’s limits belong beside the passing results.
Include a short review note with actual trade-offs
The package’s completed review note makes four choices explicit. First, it uses standard-library code so the reviewer needs no account or package installation. Second, it uses a small input limit and repeated scans to keep the decision path readable. Third, it reports unresolved sections rather than adding cycle-path extraction. Fourth, it validates parsed records while retaining a simple file-reading entry point.
The last choice has a real limitation. Python’s JSON documentation warns about CPU and memory consumption from untrusted data. This sample reads the whole input file and does not impose a byte limit before decoding. The 50-section check happens afterward, so it is not a defense against an oversized JSON file. It also does not add a special hook to reject repeated keys within raw JSON objects. Use only the supplied owned fixtures for this demonstration.
If the intended use changes, first define resource limits and raw-input requirements. For much larger graphs, reconsider the repeated scans and measure an alternative under representative inputs. Those are proposed changes; no benchmark or hardened parser was implemented here.
The provenance note states that the assistant authored the contract, source, tests and review scripts in this session. The user should not claim unobserved personal implementation or human review. The AI-assisted portfolio guide explores that separate contribution-description problem. Here the focus is selecting and handing over one requested sample.
Package the exact revision and verify the handoff boundary
Keep the entry-point file, tests, small fixture and README together. Include the actual interpreter version, successful command, expected output, rejection example and limitations. Save hashes of the source and evidence so later edits do not inherit an older passing statement. Keep the result attached to the source hash; a success screenshot alone cannot identify that revision.
Before any real submission, rerun the package from a clean permitted working directory and follow the requested delivery method. Confirm that the recipient can access the intended files only through the authorized channel; a public repository is not the default. This guide created no GitHub repository, granted no access and submitted nothing to an employer.
Choose a small example that fits the genuine task, then explain its most consequential trade-off and the checks you actually performed. Use LandOffer.ai to compare suitable opportunities, while keeping each application’s instructions, rights and assistance rules attached to its sample. No sample size, test count or writing template guarantees an interview.
Sources and Further Reading
- Atomic Object: How to Pick the Perfect Code Sample — Drew Hoover’s April 10, 2016 practitioner account; not a universal or verified current hiring rule.
- Python 3.12: unittest — test cases and runner documentation, currently labeled 3.12.15; executed sample runtime was 3.12.14.
- Python 3.12: json — parsing behavior and untrusted-input resource warning.



