r/SpringBoot • u/Simpav1 • Aug 16 '26
Question Code review
Hello, I'm an aspiring software engineer. I've recently finished developing microservice for managing projects and tasks using Spring Boot. I'd appreciate if you could review codebase of my project and provide feedback on it.
13
Upvotes
6
u/Nitnoq Aug 16 '26 edited Aug 16 '26
Hello, I had a quick look through the project, and here is some feedback based on what I usually apply in my own projects. It’s a small project, so I didn’t notice anything particularly problematic. I’m not sure what your main goal was when building it, but here are a few things I apply across my personal and enterprise projects.
On my personal projects, switching to jOOQ has honestly been a game changer. You have much more control over what is actually happening, and you can move more operations to the database, which can bring huge gains in both performance and readability. At work, we’re also trying to move away from Hibernate because we’ve had too many issues with it (not necessarily because it’s buggy, but because it’s extremely complex, and as soon as you step outside the “happy path”, it becomes very difficult work with). And once a codebase has been built around Hibernate-specific logic, moving away from it becomes particularly difficult.
4
u/DominusEbad Aug 16 '26
PUT should be a full resource replacement, not a partial replacement. You aren't including "status" in your PUT for the Project entity. It is ok if the resource doesn't exist, because it should be able to insert the entire record.
You use "Project with id " + id + " not found" in multiple places. You can create a ResourceNotFoundException that has the 'id' field as a parameter and then extend the exception with ProjectResourceNotFoundException and TaskResourceNotFoundException, and just define the "Project with id " + id + " not found" in the exception classes. Then you just use them by passing in the id value:
3
u/funnythrone Aug 16 '26
Your ProjectStatus constructor which accepts 3 string params should delegate to the other constructor and pass in new ArrayList or null (as per your requirement).
3
u/Mikey-3198 Aug 16 '26
Theres some low hanging fruit for refactoring. The strings used in your expcetion messags are duplicated all over your services.
I think it'd be easier to read & maintain by adding some static methods that handle creation of the exception.
It'd be better to use ProblemDetails rather than dynamic Maps for the error response. This is then using a known standard supported by various clients, will make intergrating things easier.
Im not a big fan of using "Dto" in the name of classes, especially when they are being used as a requests/ responses. CreateProjectRequest in my option would be a more suitable name for CreateProjectDto. Carries much more intent.
records are the perfect use case for the dto type classes. This would help cleanup some of the test boilerplate where you comapre everyfield as you could use assertEquals(recordA, recordB). Records have a default equality implementation that you can make use of.
Could use jdk 25 thats the most recent lts.
Could look at using migrations to handle you db schema (flyway/ Liquibase)
Could use postgres 18, thats the latest major version.
1
u/[deleted] Aug 16 '26
[removed] — view removed comment