5 exercises on the verb collocations developers use while actively writing code. Choose the right verb for the right context.
Key verb patterns
refactor a function — improve structure without changing behaviour
extract a method — move inline code into a named function
add a unit test — increase test coverage (also "write")
lint the code — static analysis (not "test" or "compile")
push a commit — send to remote (the git word, not "upload" or "send")
0 / 5 completed
1 / 5
A developer improves the internal structure of an existing function to make it cleaner and more readable, without changing what it does. Which phrase is most precise?
Refactor — restructure without changing behaviour:
Refactor specifically means restructuring or improving code without changing its observable external behaviour. The key constraint is that inputs produce the same outputs before and after — you only change the internal structure.
Why not the others?
rewrite implies starting from scratch or making fundamental changes — a much bigger operation
fix implies there was a defect or bug — refactoring code that works is not fixing it
update implies new requirements or new behaviour has been introduced
Core refactoring collocations:
refactor a function / refactor a method / refactor a class
refactor the codebase / refactor the data layer
extract a method (specific technique: moving inline code into a named function)
inline a variable / rename a variable / move a class
Martin Fowler's "Refactoring" catalogue (1999) formalised these terms. In code review: "This PR refactors the authentication module — no behaviour changes." In a PR title: "refactor: extract validation logic into helper."
2 / 5
A developer takes a repeated block of logic that appears in three different places and moves it into its own named, standalone function. Which phrase precisely describes this operation?
Extract a method — the canonical refactoring term:
Extract a method (or "extract a function") is the precise term from Martin Fowler's refactoring catalogue. It means: take inline code and move it into a new, named method/function that can be called from the original location and reused elsewhere.
Why not the others?
copy a method — copying without removing the original is duplication, not extraction
split a method — used when dividing one large method into two sibling methods at the same level
move a method — used when relocating an existing method to a different class or module
Related extraction patterns:
extract a variable — give a complex expression a name
extract a class — move related fields and methods into a new class
extract a constant — replace a magic number or string with a named constant
inline a method — the reverse: replace a function call with its body (when the function adds no clarity)
In a code review comment: "Could you extract this validation logic into a method? It would make the main function much easier to read."
3 / 5
A developer writes automated tests that verify the behaviour of a small, isolated piece of functionality. Which phrase is most natural?
Add a unit test — the natural collocation for expanding test coverage:
Both add and write are natural for unit tests. "Add a unit test" is especially common when increasing coverage — adding a test to an existing test file or test suite. "Write a unit test" is equally natural when authoring from scratch.
Why not the others?
make sounds non-native in this context — it is a common direct-translation error ("I will make a test" is heard from non-native speakers but not from native developers)
build is rarely used for individual tests — "build" collocates with systems, pipelines, and projects, not single tests
code is occasionally used informally ("I'll code up a test") but not the standard collocation
Natural unit test collocations:
add a unit test / write a unit test / write tests for this class
the PR added 12 new tests
the test suite / the test coverage / test the edge cases
run the tests / the tests pass / the tests fail
In a PR description: "Added unit tests for the new validation logic. Coverage for this module is now 94%."
4 / 5
A developer runs a static analysis tool across the codebase to catch style violations, unused variables, and potential logic errors. Which phrase correctly describes this action?
Lint — static analysis for style and potential errors:
Lint comes from an early Unix tool (1978) that checked C code for suspicious constructs. Today "lint the code" means running a linter to catch style issues, unused variables, potential bugs, and violations of team conventions — without running the code.
Why not the others?
test — run tests means executing the code and verifying behaviour; linting is static (no execution)
debug — debugging finds runtime issues in running code; linting is pre-execution static analysis
compile — transforms source code to executable or bytecode; linting is a separate, earlier step
Common linters by language:
JavaScript/TypeScript: ESLint
Python: Flake8, Pylint, Ruff
Ruby: RuboCop
Go: golangci-lint
Lint collocations:
lint the code / run the linter / fix lint warnings / lint errors
lint-staged — run linter only on staged files (pre-commit hook)
CI pipelines typically have three steps: lint → test → build.
5 / 5
A developer has committed their changes locally and wants to send them to the shared remote repository so teammates can see them. Which phrase is most natural?
Push — the git verb for sending commits to the remote:
Push a commit is the standard git collocation. git push sends your local commits to the remote repository. The word "push" is both the technical command and the natural conversational word.
Why not the others?
save — saving is what you do locally: write code → save the file → git commit (saves to local history). Pushing is the next step after committing.
send — generic English; not used in git vocabulary
upload — also generic; "upload" implies a one-way file transfer (like uploading to S3), not the git push model