Skip to content

Commit ff5bdab

Browse files
ivorcstefaniuk
andauthored
Code review (#91)
* Code review * Add a reference to the "Clean Code" book Co-authored-by: Dan Stefaniuk <[email protected]>
1 parent c6d1d77 commit ff5bdab

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

patterns/everything-as-code.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,45 @@ Everything (including [infrastructure](../practices/cloud-services.md)) should b
1717
## Details
1818

1919
* All code is treated the same (e.g. application code, infrastructure code, test code, etc).
20-
* All code is peer-reviewed and tested.
20+
* All code is [peer-reviewed](#code-review) and tested.
2121
* All code is version controlled.
2222
* Code changes should be automatically checked for code quality using tools like [SonarQube](https://www.sonarqube.org) (as well as via IDE plugins).
2323
* Code should be automatically scanned for secrets or other sensitive data (see [security](../practices/security.md) for details)
2424
* Prefer well structured and expressive code over extensive documentation to avoid documentation getting out of date.
2525
* Design the interface prior to the implementation and choose vocabulary to make it coherent. This includes external interfaces (e.g. REST API) and internal interfaces of classes, method signatures etc.
2626
* Adopt test-first approach to minimise waste and increase cohesion of the code (see [testing](../practices/testing.md)).
2727

28+
### Code review
29+
30+
A code review involves another member of the team looking through a proposed code change and providing constructive feedback.
31+
32+
Many teams consider code which has been written [as a pair](https://martinfowler.com/articles/on-pair-programming.html) to already have been reviewed, and do not require a separate review.
33+
34+
Robert Fink provides an excellent description of the [motivation and practice of code reviews](https://medium.com/palantir/code-review-best-practices-19e02780015f). Some key points from this and other sources ([Google](https://google.github.io/eng-practices/review/reviewer/), [SmartBear](https://smartbear.com/learn/code-review/best-practices-for-peer-code-review/), [Atlassian](https://www.atlassian.com/agile/software-development/code-reviews)) are:
35+
36+
#### Egalitarian
37+
* With the right (basic) training, anyone in the team can review anyone else's code with no hierarchy.
38+
* Everyone's code must be reviewed, no matter how experienced they are.
39+
#### Small
40+
* Code reviews should be relatively small as it is hard to review very large changes effectively.
41+
* This is one reason to break stories down as small as practical and to implement each incrementally, ensuring no single change is too large to be reviewed well.
42+
#### Meets user needs
43+
While effective testing is the best way to detect bugs or non-functional problems, code review plays an important role in spotting _potential_ issues:
44+
* Does the code look like it will meet the acceptance criteria, or are there obvious errors or omissions?
45+
* Does it handle edge cases?
46+
* Are common issues guarded against relating to security (e.g. [OWASP Top 10](https://owasp.org/www-project-top-ten/)), performance, scalability or robustness?
47+
#### Of high quality
48+
* Is the code clear and simple?
49+
* Is the code layout and structure consistent with agreed style and other code?
50+
* Would it easily allow future modification to meet slightly different needs, e.g. ten times the required data size or throughput?
51+
2852
## Examples
2953

3054
* Application code written in languages such as Python, Java or C#.
3155
* Application configuration, held in files (e.g. YAML, Json) held in source control.
3256
* Declarative infrastructure as "code" (actually often YAML or HCL).
3357
* Database migrations: SQL scripts held in source control.
58+
59+
## Further reading
60+
61+
* [Clean Code: A Handbook of Agile Software Craftsmanship](https://learning.oreilly.com/library/view/clean-code-a/9780136083238/)

patterns/governance-side-effect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Automate preventative measures and ongoing compliance checks to ensure systems m
3333
Properly configured tooling supports good practice and provides an audit trail through the whole software delivery lifecycle:
3434
* Use of an issue tracking system such as Jira ensures changing requirements are visible over time.
3535
* Use of issue references in source control commit messages (which can be enforced with commit hooks) ensures code changes can be traced back to a business requirement.
36-
* Source control systems provide visibility of who changed what when, and enforce and record peer review approvals.
36+
* Source control systems provide visibility of who changed what when, and enforce and record [peer review](everything-as-code.md) approvals.
3737
* Continuous integration systems record the result of build and test stages as well as deployments to each environment, including who did what when.
3838
* Integration of CI/CD systems with change management systems ensures a consistent view of changes are visible.
3939
* Cloud platforms provide logs of changes to resources, e.g. AWS CloudTrail.

0 commit comments

Comments
 (0)