Open macg20 opened 2 years ago
Assuming you want to write a wrapper over some primitive tech (like JdbcTemplate or whatever), I'd just implement it directly in the same file. Just like InMemoryRepository. I know, religious zealots will say right away that this is infrastructure, and therefore should be down in the infra package (thus requiring Repo interface to become public), but I'm agnostic and pragmatic - I give no damn about religion. Everyone understands that Repo is infra, but limiting visibility by package scope is more important (and easy to get wrong). In fact I have implemented my own version of production ready repos exactly this way (for example to handle thread pools in non-reactive driver with subsribeOn). Worked like a charm, nobody made any mistakes with that for the next 3 years in 2 companies (so no problems for 7 years at least). But then again, I'm agnostic and pragmatic. I wouldn't be able to do that in a highly religious environment.
Thank you for your answer!
Tangential to the topic but... I have made a compromise in some cases where repositories where already coded and tested in a different module. What I did in that case was to mock the repositories. It worked well for my use case of very loosely coupled microservices that just read events and trigger repo calls/create other events.
Hi.Could you explain how to implement FilmRepository without SpringDataJpa and InMemory? Should FilmRepository be public then? Should the implementation FilmRepository then be in the infrastructure package? How can I do this while keeping the current package structure and package scope? Could you give an example?