I am developing a client application for searching flights tickets. I have obtained a JSON with search result from server and I should express this result to client.
Suppose I have a Fare, AirlineCompany and AviaTicketSearchResult objects. AviaTicketSearchResult should contain list of AirlineCompany objects. Each AirlineCompany should contain Fares. And I guess that AviaTicketSearchResult and AirlineCompany are an Aggregate root, because I have the rule of Cascading Delete, when I delete AirlineCompany it make sense to delete all airlineCompany’s fares same with AviaTicketSearchResult.
1) Is it ok to contain list of Fares inside an aggregate root (AirlineCompany)?
Another problem is that I should to have a filter ability for Fares inside AirlineCompany. Each Fare has a itinerary and every itinerary has a list of variants (ItineraryVariant) (different legs, travel etc.). When I accept the filter I should update my AirlineCompany and remove unnecessary Fares or remove unnecessary ItineraryVariant inside concrete Fare.
2) How to apply ability of filtering?
I am assuming that I should represent Fare as VO and recreate Fare object from raw data (json) each time when I apply the filter and then add it to AirlineCompany after all update AviaTicketSearchResult with filtered AirlineCompany.
I don’t think that Domain-Driven Design is a good fit here. As far as I can tell you’re just talking about a couple of DTOs for the UI and some means to filter them.
Domain-Driven Design comes in handy when you’re trying to grasp (and model) complex behavior. View Models or DTOs should be as simple as possible. Most of the time there’s no need for sophisticated and time-consuming modeling efforts.
Or, as Eric Evans puts it: