Mieszko Malawski
Mieszko Malawski

Reputation: 103

Domain Driven Design: infrastructure concern or domain concern?

I cannot decide whatever this is infrastructure or domain responsibility:

User can pass date range in url query, eg dateStart=2016-04-12 , dateEnd=2016-04-15. Based on that date range we return list of entities that have field createdOn between these two dates. To make this work correctly I must convert 2016-04-12 to 2016-04-12 00:00:00 and 2016-04-15 to 2016-04-15 23:59:59, is this conversion should be considered infrastructure concern ( and should be put in repository, or maybe application layer ) or bussiness rule ( and should be put in service or entity ) ?

Upvotes: 1

Views: 129

Answers (2)

VoiceOfUnreason
VoiceOfUnreason

Reputation: 57377

is this conversion should be considered infrastructure concern ( and should be put in repository, or maybe application layer ) or bussiness rule ( and should be put in service or entity ) ?

As noted by plalx, DateRange/TimeInterval is likely an important concept on its own, and should be represented as a value type in your model.

Taking the user inputs that you get, and expressing them in the types represented by your model is an application concern.

Finding a list of entities that satisfy that constraint should be a repository concern. It can be useful to make that constraint explicit in your repository contract - it serves to document what capabilities you need in the underlying stores.

Upvotes: 3

aniski
aniski

Reputation: 1271

I would create an Util object (class), which would provide the converter method for you.
You have to decide about how would you use the format in your deepest layers (some kind of repository?). If that format is not the same as it would be shown on the application layer, than you'd have to use the conversation somewhere (I suggest the top of your backend API), but be ready to use validation inside the repository layer etc. as well.

Upvotes: 0

Related Questions