lundi 16 juillet 2018

Relationships between entities in an MVC domain model

I have a web MVC application consisting of three layers, separated from each other:

  • A UI layer: consists of controllers, presenters, views, etc;
  • A domain model: a layer containing entities (domain objects) and database abstractions (repository interfaces - as Separated Interfaces),
  • A persistence layer: consisting of repository implementations - as Gateways.

In its definition of Domain Model, Martin Fowler says:

A Domain Model creates a web of interconnected objects, where each object represents some meaningful individual, [...].

He also presents a database in the image preceding his description.

Personally, because in my persistence layer I am not using any ORM, ActiveRecord, or similar implementations, I can't imagine that I need some kind of relational mapping between the entities and the database structure - including here the relationships between the database tables too.

But then, do I still need to construct any relationships between the entities? In other words, do I need to interconnect them, like: A Question entity contains a list of Comment entities?

If yes, could you please explain to me, what the purpose of this "interconnectivity" could, or should be?

Thank you for your time.

Aucun commentaire:

Enregistrer un commentaire