C
C#4w ago
Dovydas

Repository-Service-Model pattern

I am working on a Blazor web app and am confused about the Repository-Service-Model pattern, especially the roles of the service and model layers. Currently, I find myself calling repository methods through the service layer and then calling service methods through the model layer, which feels redundant. Am I misunderstanding the purpose of these layers, or is there a more efficient way to structure this pattern?
2 Replies
Sossenbinder
Sossenbinder4w ago
With model layer, you probably refer to the "view", I assume? So some kind of view model? That architecture is generally known as 3-tier or N-tier if there's more to it. It's probably one of the more common architectures, because on paper it allows to separate logic for UI concerns, business logic and data persistence logic. But you already stumbled over one of it's cons, it can be a lot of boilerplate if you don't really have any need for these layers It mainly starts to actually yield benefits when you have reusable or more complex business logic which is not just passing through When it comes to improving it... I'd say it's a matter of flexibility. Are you pragmatic and willing to cut out unnecessary abstractions, or do you prefer to stick to a dogmatic ruleset in order to potentially allow your future self to have a single point of change?
shua
shua4w ago
There is no such thing as the "Repository-Service-Model" pattern, where did you get that from? There is a "service repository pattern" though which I'm assuming is what you are talking about?
Want results from more Discord servers?
Add your server