Video in progress

In code review, which OOP and design problems do you look at first?

First the logical boundaries: is the logic in the right class, is encapsulation intact (setters, exposed collections), does a new dependency break the layers. Then names, error handling and tests. I leave style issues to the linter.

📖 Answer

My list (roughly in order of importance):

  1. Where does the logic live? In a service, if (order.getStatus() == PAID && order.getLines().size() > 0): should this be order.isShippable()? Feature envy and the anemic model are born here.
  2. Encapsulation. A new public setter, a mutable List leaking out through a getter, an inner class that became public.
  3. Direction of dependencies. Is RestTemplate or a controller DTO imported into the domain package? Is there a new circular dependency?
  4. Names. data, info, process(), handle2(): if a name doesn't say what the logic is, the next reader gets lost.
  5. Errors. A swallowed exception (catch (Exception e) {}), returning null, a generic RuntimeException.
  6. Tests. Is there a test for the new rule? Does the test check behavior, or does it only count mock calls?

Formatting, import order, braces: Checkstyle/Spotless handles those. Writing about them in review wastes people's time and buries the important comments.

Another habit: I phrase comments as questions ("what would this look like inside Order?"), not as commands. The author often knows the context better.