DDD Scheduling Flights

by Connor Wyatt   Last Updated October 05, 2018 01:05 AM

I'm fairly new to DDD and have been building a virtual airline app for flight simulators and I'm having trouble modelling the scheduling part of the app.

A bit of the domain details: first you start an airline, then you use your money to buy aircraft. Then you schedule flights, fly them and earn money. Any clashes in scheduling, either a double booked pilot or aircraft will not be prevented, but will be displayed to the user to get them to solve the clash. Same goes for if the aircraft is scheduled to be at airport A when a flight from airport B is scheduled to take place in in the same aircraft, you'd have to solve it by adding a flight from A to B at some point to make it valid.

So my question is how I would model the scheduling. I think scheduling should be an aggregate root, something like ScheduleWeek or ScheduleMonth but then I run into the issue of what if a scheduled flight spans two weeks? E.g. it starts near end of one week and ends after the start of the following week.

I've had a couple of thoughts, the first being that I duplicate it, so the flight would be in two schedule weeks, however I imagine I would need a saga for when a user wants to change the time of the flight as I would need to ensure both schedules are updated.

My other idea is that maybe I should model it as a moving timeframe, e.g. allow flights to be scheduled for the next 3 months and archive scheduled flights after they have expired, however this just feels like it might be an antipattern to me as flights would have to be removed. (I am using event sourcing though so they wouldn't be deleted completely)

Happy to elaborate on anything if anyone feels I haven't explained the domain or my ideas well enough. Also perfectly willing to accept I might have modelled this completely wrong and that there is a better model that what I'm considering.


Related Questions

Domain model design

Updated July 23, 2016 08:02 AM

What is a domain?

Updated October 23, 2017 18:05 PM