What's changed: Initial version
5.5Code review and interpreting sequence diagrams
Builds the ability to grow automation code safely through code review principles (small PRs; emphasis on readability/correctness/security; knowledge sharing) and their benefits, and to read the order and dependency of API calls (token fetch -> GET -> 429 -> retry, etc.) from a sequence diagram (actors/lifelines, request/response arrows, time flowing top to bottom).
Automation is not write-once but the practice of a team changing it safely over time. Two practices for that are this section's theme. One is code review—a mechanism where a third party reads a change before it enters production to check bugs, readability, and security. The other is reading a sequence diagram—the ability to grasp from a diagram in what order and what several components (client, API, auth server) exchange. Both are learned not as memorization but as material for interpreting a given review situation or diagram and judging the next move.
5.5.1Code-review principles and benefits
- The aims of review are early bug detection, readability/maintainability, security, and knowledge sharing. Having a third party read a change before production catches hardcoded plaintext passwords, dangerous deletions, and missed boundary conditions before release. It also strongly prevents siloed knowledge and shares design intent across the team.
- Good review practice: keep PRs small (smaller diffs mean fewer misses), focus on correctness, readability, and security, and comment constructively on the code, not the person. Comments should be specific and grounded, ideally with a suggested fix. Layering human review on top of passing CI automated checks (lint/tests) is efficient.
5.5.2Reading a sequence diagram
- A sequence diagram consists of actors/objects at the top (e.g., Client / Auth Server / API), the lifelines (vertical lines) descending from them, and message arrows connecting them. Time flows top to bottom, and an arrow's direction shows the call direction. A solid arrow = a request (call) and a dashed return arrow = a response is the common notation.
- The knack for reading an API-integration diagram is order and dependency: e.g., "Client -> Auth: request token / Auth -> Client: token (response) / Client -> API: GET (with Bearer token) / API -> Client: 200 + data" reveals the dependency that authentication comes first, data fetch after. If
API -> Client: 429appears midway, the diagram shows the need for rate-limit handling -> wait and retry.
Most-tested: review = secure bugs/readability/security/knowledge-sharing before production, keep PRs small, comment on the code not the person; a sequence diagram = actors plus lifelines, time top-to-bottom, arrow direction = call direction, solid request / dashed response; read order and dependency from the diagram (fetch token -> call API / 429 -> wait and retry). Practice interpreting a diagram or review situation and choosing the next move.
Suppose you are reviewing a colleague's Pull Request. The diff is a Python script calling a Cisco platform's token-auth API, and the attached sequence diagram is: Client -> Auth Server: request token with credentials / Auth Server -> Client: access token (response) / Client -> API: GET /devices (Authorization: Bearer <token>) / API -> Client: 200 OK + device list. The diagram first tells you the order: fetching the token comes first, and fetching the device list depends on it. But reading the code, it calls GET /devices first and fetches the token afterward—the implementation order is the reverse of the diagram's dependency (auth first). This is a "diagram/implementation mismatch"; running it, a request without the auth header is rejected with 401 Unauthorized—a clear bug to flag in review. Further, the diagram's right side depicts a branch for heavy loops, API -> Client: 429 Too Many Requests, yet the code has no wait/retry (backoff) on 429, so it fails wholesale on rate limiting. That too is an implementation gap against the control the diagram assumes. Make review comments specific, grounded, and with a suggested fix: "(1) Per the diagram's dependency, move the token fetch before GET /devices (currently it 401s). (2) Matching the diagram's 429 branch, add a wait-and-retry that respects Retry-After." What to avoid is vague attacks on character or impression like "this code is sloppy"; review should focus on the code's correctness, readability, and security, delivered constructively. The lesson: a sequence diagram can be read as "the spec of the intended order and dependency," and checking whether the implementation matches it is a concrete weapon in review.
| Element/situation | Reading | Next move |
|---|---|---|
| Lifelines + top-to-bottom | Each actor's timeline; higher = earlier | Grasp the order of operations |
| Solid -> / dashed <-- | Solid = request (call), dashed = response (return) | Track request/response pairs |
| token -> GET ordering | Auth first, data fetch depends on it | Check the implementation follows the same order |
| API -> Client: 429 | A branch where rate limiting can occur | Implement/verify wait-and-retry |
Trap: "Code review is enough if it just tidies coding style (indentation, etc.)" is wrong—its essence is correctness, security, readability, and knowledge sharing, and the main goal is catching behavior/safety defects like plaintext secrets or diagram/implementation mismatches (reversed order causing 401, missing 429 retry). Also, comment on the code, not the person, specifically and with a suggested fix. In a sequence diagram, do not confuse that time flows top to bottom and the arrow direction is the call direction.
5.5.3Section summary
- Code review secures bugs, readability, security, and knowledge sharing before production; keep PRs small and comment on the code, not the person, specifically and with grounds
- A sequence diagram uses actors plus lifelines with time top-to-bottom and arrow direction = call direction (solid request / dashed response); read order and dependency
- Use the diagram as "the spec of intended order/dependency" and check for implementation mismatches (auth deferred causing 401 / missing retry on 429) to decide the next move
Sign in to track progress — Log in.
Quick check
(just a quick review)Q1. While reviewing a colleague's PR, the attached sequence diagram shows "Client -> Auth: request token / Auth -> Client: token / Client -> API: GET (with Bearer) / API -> Client: 200," but the code calls GET first and fetches the token afterward. Which review comment is most appropriate?
Q2. A sequence diagram for automation looping over many devices depicts a branch "API -> Client: 429 Too Many Requests," but the code under review has no wait/retry on 429. Which comment is most appropriate?
Q3. A team is deciding its review policy for automation code. From the exam's viewpoint, which best represents "effective code review"?
Keep track of your progress
The full study guide is free to read. Sign up free to practice with the question bank, track what you have read, review your mistakes, and highlight passages.

