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):
- Where does the logic live? In a service,
if (order.getStatus() == PAID && order.getLines().size() > 0): should this beorder.isShippable()? Feature envy and the anemic model are born here. - Encapsulation. A new public setter, a mutable
Listleaking out through a getter, an inner class that becamepublic. - Direction of dependencies. Is
RestTemplateor a controller DTO imported into the domain package? Is there a new circular dependency? - Names.
data,info,process(),handle2(): if a name doesn't say what the logic is, the next reader gets lost. - Errors. A swallowed exception (
catch (Exception e) {}), returningnull, a genericRuntimeException. - 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.
Sign up to mark studied questions and save your progress.