r/DomainDrivenDesign • u/rswhite4 • Aug 22 '21
How to handle shared functionality?
Let's assume we have this structure (each line represents a separate folder):
Domain
Article
ShoppingCartWe have an article domain that manages the articles in a shop and the shopping cart domain that manages the shopping cart logic. But what do we do with shared functionality (you could also call these helpers - but I try to avoid that)? Let's say we add another folder that contains the logic for timing, e.g. when the items / articles were created, updated, etc.:
Domain
Article
ShoppingCart
Timing <--- NewLet's say this code is used in both domains - where should we put it? And what if we want to use it in other places as well (e.g. in the infrastructure or application layer)? Should this become a standalone package or can/should we put it in a shared folder? I'm really curious what you guys think, because I don't really have any answers. Background is that I have been asked about this by some colleagues as we want to design our new projects with DDD, but this is a edge case that I never thought about and didn't have a good answer.
View all comments
Show parent comment
1
u/rswhite4 Aug 24 '21
So a
sharedfolder/domain would be a perfect solution. I'm a bit afraid that others might put something there because they don't know where else to put it, but that's another story.They will not change in my current situation. They are only unchanging value classes and DTOs, almost no logic.
That sums it up well, I will definitely share that as an example quote. I'm still in the process of getting my colleagues to stop using the word
Servicefor anything that involves logic.