I asked Uncle Bob
on Twitter, but I'll ask here again: how do you implement associations/relationships with Clean Architecture, or Entities-Boundaries-Interactors design? I'm trying to refactor a Rails app which just happens to be a payroll app, similar to what Uncle Bob uses in some examples. There are some complex relationships such as User -> has_many -> Shifts -> through -> AssignedShifts, and Schedule -> has_many -> Shifts -> through -> ScheduledShifts. Some of these can clearly be Inheritance, such as Shifts -> ScheduledShifts -> AssignedShifts. But how do I handle these relationships? Do I store them in the entities themselves in instance variables? Or do they go in Repository objects? It seems that a user having shifts is non-application specific domain logic. But I want to keep the entities ignorant of the database. Should I use relational algebra (with a gem like
Axiom) to model relationships between entities? This seems a little like re-implementing the database at the model level. Am I not thinking in a properly object-oriented way here, or is this just the level of effort needed to separate business logic from persistence details?