ArticleslgStudy

computer science

Code review

Code review is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Code review rather than just read about it. In short: Code review (sometimes to as peer review) is a software quality assurance activity in which one or more people examine the source code of a computer program, either after implementation or during the development process. The persons performing the checking, excluding the author, are called "reviewers".

Code review — main illustration
Code review — illustration

Key takeaways

  • Code review belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Code review to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Code review from memory before moving on to harder problems.

Reference excerpt

Code review (sometimes to as peer review) is a software quality assurance activity in which one or more people examine the source code of a computer program, either after implementation or during the development process. The persons performing the checking, excluding the author, are called "reviewers". At least one reviewer must not be the code's author. Code review differs from related software quality assurance techniques like static code analysis, self-checks, testing, and pair programming. Static analysis relies primarily on automated tools, self-checks involve only the author, testing requires code execution, and pair programming is performed continuously during development rather than as a separate step.

Goal Although direct discovery of quality problems is often the main goal, code reviews are usually performed to reach a combination of goals:

Improving code quality – Improve internal code quality and maintainability through better readability, uniformity, and understandability Detecting defects – Improve quality regarding external aspects, especially correctness, but also find issues such as performance problems, security vulnerabilities, and injected malware Learning/knowledge transfer – Sharing codebase knowledge, solution approaches, and quality expectations, both to the reviewers and the author Increase sense of mutual responsibility – Increase a sense of collective code ownership and solidarity Finding better solutions – Generate ideas for new and better solutions and ideas beyond the specific code at hand Complying with QA guidelines, ISO/IEC standards – Code reviews are mandatory in some contexts, such as air traffic software and safety-critical software

Review types Several variations of code review processes exist, with additional types specified in IEEE 1028.

Management reviews Technical reviews Inspections Walk-throughs Audits

Inspection (formal) The first code review process that was studied and described in detail was called "Inspection" by its inventor, Michael Fagan. Fagan inspection is a formal process that involves a careful and detailed execution with multiple participants and phases. In formal code reviews, software developers attend a series of meetings to examine code line by line, often using printed copies. Research has shown formal inspections to be extremely thorough and highly effective at identifying defects.

Regular change-based code review (walk-throughs) Software development teams typically adopt a more lightweight review process in which the scope of each review relates to changes to the codebase corresponding to a ticket, user story, commit, or some other unit of work. Furthermore, there are rules or conventions that integrate the review task into the development workflow through conventions like mandatory review of all tickets, commonly as part of a pull request, instead of explicitly planning each review. Such a process is called "regular, change-based code review". There are many variations of this basic process. A 2017 survey of 240 development teams found that 90% of teams using code review followed a change-based process, with 60% specifically using regular change-based review. Major software corporations known to use changed-based code review include Microsoft, Google, and Facebook.

Efficiency and effectiveness Ongoing research by Capers Jones analyzing over 12,000 software development projects found formal inspections had a latent defect discovery rate of 60-65%, while informal inspections detected fewer than 50% of defects. The latent defect discovery rate for most forms of testing is about 30%. A code review case study published in the book Best Kept Secrets of Peer Code Review contradicted the Capers Jones study, finding that lightweight reviews can uncover as many bugs as formal reviews while being faster and less costly. Studies indicate that up to 75% of code review comments affect software evolvability and maintainability rather than functionality, suggesting that code reviews are an excellent tool for software companies with long product or system life cycles. Therefore, less than 15% of issues discussed in code reviews relate directly to bugs.

Guidelines Research indicates review effectiveness correlates with review speed. Optimal code review rates range from 200 to 400 lines of code per hour. Inspecting and reviewing more than a few hundred lines of code per hour for critical software (such as safety critical embedded software) may be too fast to find errors.

Supporting tools Static code analysis tools assist reviewers by automatically checking source code for known vulnerabilities and defect patterns, particularly for large chunks of code. A 2012 study by VDC Research reports that 17.6% of the embedded software engineers surveyed currently use automated tools to support peer code review and 23.7% plan to use them within two years.

See also Committer Software review Software quality Best coding practices List of software development philosophies

External links Five Code Review Antipatterns Java Magazine, Best of 2020

References

Illustrations

Code review: Software engineers (a.k.a. programmers) reviewing a program
Software engineers (a.k.a. programmers) reviewing a program

Worked examples

Example 1 — a first encounter with Code review

Start with the simplest possible case. Write down what Code review claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Code review before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Code review ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Code review

In research
Code review appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Code review in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Code review is common in secondary-school and first-year university syllabi. It links to neighbouring topics Peer review, Software review, Source code, so understanding it makes those chapters shorter.
In everyday life
Look for Code review outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Code review” →

How to study Code review in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Code review means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Code review out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Code review in simple terms?

Code review (sometimes to as peer review) is a software quality assurance activity in which one or more people examine the source code of a computer program, either after implementation or during the development process. The persons performing the checking, excluding the author, are called "reviewe…

Why does Code review matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Code review?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Code review.

Tags

  • Peer review
  • Software review
  • Source code

Keep exploring