IntermediateTopic 52 of 104Software & Computing
Code review and refactoring
Improve design without changing behaviour; peers catch bugs.
In depth
Code review improves quality and shares knowledge via peer inspection of changes. Refactoring restructures code without changing behaviour to reduce duplication and complexity: extract method, rename, introduce parameter object. Rely on tests and small steps. Static analysis supports both.
Key points
- Code smells
- Pull requests
- Technical debt
ExampleExtracting a 100-line function into well-named smaller ones.
What is Code review and refactoring?
Improve design without changing behaviour; peers catch bugs.
Why is it important to understand code review and refactoring?
Code review and refactoring keep code clear and correct over time, and peers often find bugs that the author misses.
What should a reviewer look for?
Correctness, clarity, edge cases, security, tests and consistency with the existing design, while keeping the review respectful and focused.
What is refactoring?
Changing the internal structure of code without changing its external behaviour, which is verified by tests.
How is Code review and refactoring used in practice?
Typical applications include reviewing a pull request that changes a payment calculation, renaming and splitting a long function without changing its behaviour and asking a colleague to check the error handling in a new module.
What should I learn before Code review and refactoring?
Study "Integration and system testing" first (topic 51 of 104 in Software & Computing). It covers the groundwork this topic builds on.
What are the key points of Code review and refactoring?
Code smells. Pull requests. Technical debt.
Can you give an example of Code review and refactoring?
Extracting a 100-line function into well-named smaller ones.
What comes after Code review and refactoring?
The next topic is "CI/CD", which builds directly on this one.
How difficult is Code review and refactoring?
It is classed as Intermediate in Software & Computing (topic 52 of 104). It is an intermediate topic. Work through the beginner topics in Software & Computing first.