eShopOnWeb Architecture (12/16) – uses the repository and specification pattern

eShopOnWeb uses the repository pattern over Entity Framework ((I’m not getting into this debate again 😉). When we use this pattern we can sometimes see a proliferation of similar methods such as GetBasketByBuyerId, GetBasketByBasketId etc.

eShopOnWeb uses the specification pattern to encapsulate queries and their details. This means we don’t have a proliferation of repository methods but rather just a few (eg. GetBySpecAsync) which take a ‘specification’ as input. The queries however have really just been moved to another location and we’ll likely still have a similar amount of specifications as repository methods.

For example… below we can see that instead of having two repository methods with a query each for GetBasketByBasketId and GetBasketByBuyerId scenario eShopOnWeb has a BasketWithItemsSpecification class which has two queries via two different constructors.

Click on the image for a larger view in a new tab…

What does everyone think? … for me this is kind of like taking an abstraction (the repository pattern) and then splitting it in two. It’s makes the architecture harder to navigate and understand for little if any benefit.

One thought on “eShopOnWeb Architecture (12/16) – uses the repository and specification pattern”

Leave a Reply

Your email address will not be published.