DEV Community

Philip Perry
Philip Perry

Posted on

3 2

Repository/Service pattern, did it finally click?

If you don't know what the repository and service patterns are, check out this article:

https://www.vodovnik.com/2015/08/26/repository-and-services-pattern-in-a-multilayered-architecture/

While I had made use of the repository pattern before, I still made the mistake of putting the method getOfficeContactData() into a service class, even though the name (the data part) should have made it obvious that this is something that belongs into a repository class. In addition, it was shared by two service classes!

Thanks to my code reviewer who pointed it out to me. I think I now understand the purpose of each layer better and will pay more attention to where I put methods in the future.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more