cat blog/ce-que-la-revue-de-code-ma-appris-en-encadrant-une-equipe.md
What code review taught me while leading a team
Solution Architect


Contents
- Mistake 1: reviewing to correct, not to grow
- Mistake 2: commenting on style instead of what matters
- Mistake 3: pull requests too big, reviewed too late
- Mistake 4: the tone of comments
- Patterns: stop repeating the same comments
- The design patterns that kept coming up in review
- The SOLID principles behind the comments
- On the Flutter side: architecture and state management
- A series of articles to follow
- My review checklist today
- In short
Since 2021, I've worked at three web agencies, and in each of them, code review was part of my daily routine. At one of them, for two years, I led web and mobile development while supervising a small team of junior developers: Laravel and Vue.js on the web, Flutter on mobile. That's where code review took up a good part of my days, and that's where most of the examples in this article come from.
I started out thinking reviewing meant catching bugs before production. I came out convinced that code review is first and foremost a teaching tool, and that done badly, it slows a team down as much as it protects it.
Here are the four mistakes I made, and what I do differently today.
Mistake 1: reviewing to correct, not to grow
At first, when I saw a problem, I gave the solution: "replace this loop with a whereIn query", "move this logic into a service". The code improved, but the same mistake came back in the next pull request. The developer applied my fix without understanding why.
I had become a proofreader, not a mentor. And the team depended on me for every slightly tricky decision.
What I changed: I ask a question before giving an answer. "How many queries does this loop send if the list has 500 items?" goes further than a ready-made fix. When the topic deserves it, I take ten minutes live to explain the principle, then let the developer fix it themselves.
The most frequent case was the N+1 query, invisible locally with ten rows of test data, disastrous in production:
// Before: 1 query for the orders + 1 query per customer
$orders = Order::latest()->take(500)->get();
foreach ($orders as $order) {
echo $order->customer->name; // 501 queries in total
}
// After: eager loading, 2 queries in total
$orders = Order::with('customer')->latest()->take(500)->get();
Rather than writing the fix, I'd ask them to open Laravel Debugbar and count the page's queries. The developer found with() on their own, and never made the mistake again. To go further, one line in AppServiceProvider turns this trap into an explicit error during development:
Model::preventLazyLoading(! app()->isProduction());
Mistake 2: commenting on style instead of what matters
My first reviews were full of remarks about spacing, import order, a variable name. A pull request could get twenty comments, eighteen of them about form. The two that really mattered, an authorization flaw or a query that would collapse under load, drowned in the rest.
For a junior, twenty comments also send a discouraging message: "everything is wrong".
What I changed: anything a machine can check, a machine checks. Formatting with Pint and Prettier, static analysis with Larastan, run automatically in CI on every push. Human review focuses on what no tool sees:
does the code do what the requirement asks?
is there a security risk (permissions, validation, exposed data)?
will it hold up at scale (N+1 queries, missing indexes)?
will the next developer understand this code in six months?
Concretely, three steps in the GitHub Actions workflow are enough to take form out of human review:
- name: Style
run: vendor/bin/pint --test
- name: Static analysis
run: vendor/bin/phpstan analyse --memory-limit=1G
- name: Tests
run: php artisan test --parallel
A red pull request isn't reviewed. When it's green, I know my time will go to what matters.
Mistake 3: pull requests too big, reviewed too late
I let developers work for days on a feature before opening the pull request. The result: dozens of files changed at once, which I skimmed for lack of time. And when I found a design problem, it was too late: everything had been built on top of it, and the developer experienced the fix as a failure.
Another side effect: pull requests waited. Since they took long to review, I postponed them, and the team stayed blocked waiting for my green light.
What I changed:
short pull requests, one intent each, even if it means several per feature;
a draft pull request from the start, to validate the approach before everything is written;
a same-day review turnaround: reviewing fast saves the team more time than reviewing perfectly;
shared reviewing: juniors also review each other, which trains them as much as my own feedback.
Mistake 4: the tone of comments
In writing, without tone of voice, a neutral comment can sound like a reproach. "Why did you do this?" meant "walk me through your reasoning" to me. To a junior, it often meant "you got it wrong". Some ended up no longer proposing ideas, for fear of being corrected.
What I changed:
comment on the code, never the person: "this function does two things" rather than "you mixed two responsibilities";
say what's blocking and what isn't, with a simple prefix: blocking, suggestion, question;
explain the why, with a link to the docs or an example when useful;
also point out what's well done. A "nice catch on this edge case" costs three seconds and shows what to repeat;
switch to a call as soon as a thread passes three messages. Five minutes of talking settle what ten comments complicate.
Here's what my comments looked like before and after:
Before:
Why are you validating here?
After:
suggestion: this validation could move to a FormRequest
(StoreOrderRequest). The controller stays short and the rules
become testable on their own. Example: app/Http/Requests/StoreUserRequest.php
The prefix comes from the Conventional Comments convention: it says in one word whether the comment blocks the merge or not.
Patterns: stop repeating the same comments
After a few months, I noticed I kept writing the same remarks: "this controller does too much", "this logic is duplicated in two places", "this if on the payment type will grow with every new method". A comment that keeps coming back isn't a developer problem, it's a pattern the team is missing.
The typical case is the controller that keeps growing:
// Before: the controller validates, computes, saves, notifies
public function store(Request $request)
{
$data = $request->validate([/* 15 rules */]);
$total = /* 20 lines of computation */;
$order = Order::create([...$data, 'total' => $total]);
Mail::to($order->customer)->send(new OrderConfirmed($order));
return redirect()->route('orders.show', $order);
}
// After: each responsibility has its place
public function store(StoreOrderRequest $request, CreateOrder $createOrder)
{
$order = $createOrder->handle($request->validated());
return redirect()->route('orders.show', $order);
}
The FormRequest handles validation, the CreateOrder action holds the business logic, and the email moves to an event handled by a listener. Once these patterns were written down in a short team guide, my comments often boiled down to a link: "see the Actions section of the guide".
The design patterns that kept coming up in review
Beyond Laravel's own conventions, several classic patterns directly answered recurring comments:
Pattern | The review problem it solves | Caveat |
|---|---|---|
Form Request | Validation mixed into the controller | Laravel-specific; NestJS has DTOs and |
Action (or Service) | Business logic duplicated or buried in the controller | One action = one use case, not a catch-all |
Policy | Permissions checked by hand, or forgotten | In NestJS, the equivalent goes through Guards |
Repository | Scattered data access, impossible to fake in tests | With Eloquent, often unnecessary; essential in Flutter |
Singleton | An API client or connection recreated on every call | Use the container ( |
Factory | Conditional | Centralize creation, not logic |
Strategy |
| Ideal for payment or delivery methods |
Observer (Events) | Side effects (emails, notifications) glued to business code | Events hide the flow: name them well |
The SOLID principles behind the comments
Rereading my old reviews, I realized most of my remarks were SOLID principles that didn't say their name. Naming them changed the discussion: we no longer debated my taste, but a shared principle.
Review comment | Principle |
|---|---|
"This controller validates, computes, saves and notifies." | S: single responsibility |
"This | O: open for extension, closed for modification |
"This subclass throws on an inherited method." | L: Liskov substitution |
"This interface forces implementing five useless methods." | I: interface segregation |
"You're calling | D: dependency inversion |
On the Flutter side: architecture and state management
In mobile apps, the most frequent comment was always the same: the logic lived in the widgets. A screen called the API, parsed the JSON and handled errors in its initState:
class _OrdersPageState extends State<OrdersPage> {
List<dynamic> orders = [];
@override
void initState() {
super.initState();
// Network call, parsing and state mixed in the widget
http.get(Uri.parse('$baseUrl/orders')).then((res) {
setState(() => orders = jsonDecode(res.body));
});
}
// ...
}
Impossible to test, impossible to reuse, and every screen reinvented its own loading and error handling. The answer came from Clean Architecture, applied per feature:
lib/features/orders/
├── data/ # OrderRepositoryImpl, API calls, JSON models
├── domain/ # Order entity, OrderRepository contract, GetOrders use case
└── presentation/ # screens, widgets and state (Bloc or Riverpod)
The widget only displays a state. State is handled by a dedicated layer, and the domain doesn't even know Flutter exists. What remained was choosing how to manage that state: setState, Provider, Riverpod or Bloc. Each has its place, and the wrong choice costs a lot as the app grows.
A series of articles to follow
Each of these topics deserves far more than a table. They'll make up a series, each article linking to the previous one:
The design patterns I use every day, in Laravel and NestJS: Repository, Singleton, Factory, Strategy, Observer, with their pitfalls.
SOLID principles in practice, from real review comments.
Clean Architecture with Flutter: splitting an app by feature and by layer.
State management in Flutter:
setState, Provider, Riverpod or Bloc, and how I choose.
My review checklist today
This is the list I keep in front of me when reviewing, in this order. If an item near the top is a problem, no need to go further down: we talk about it first.
[ ] The requirement: does the code do what's asked, edge cases included?
[ ] The design: is it in the right place, the right layer (controller, action, model), following the team's patterns?
[ ] Security: permissions checked, inputs validated, no sensitive data exposed?
[ ] Performance: no query in a loop, indexes present, pagination where needed?
[ ] Tests: are the main case and at least one error case covered?
[ ] Readability: would a newcomer understand this code without explanation?
[ ] Tone: does every comment say whether it's blocking, and why?
Formatting isn't on it: CI takes care of it before I even open the pull request.
In short
Code review isn't a quality check placed at the end of the chain. It's the moment a team learns to write code together. A good review isn't measured by the number of problems found, but by the number of problems that stop coming back.
If I had to sum it all up for someone starting to lead: automate form, review early and often, ask questions before giving answers, and never forget there's a person behind every pull request.
Up next: the first article of the series, on the design patterns I use every day in Laravel and NestJS.
subscribe --blog
Get new posts by email
One email per new post, nothing else. Unsubscribe in one click.
Your address is only used to send you new posts. Privacy
ls ./related-articles



