Domain Driven Design (DDD)
within this issue I'd like to collect notes and thoughts about the approach we use when implementing interaction between the GUI and the data model mappings (ramsis.datamodel
).
After reading Martin Fowlers article discussing the pros and cons of the anemic domain model I personally rather would tend to the DDD approach. The remaining question still is how to implement this Fat-Model approach most elegantly. Basically, there are two approaches to tackle the problem:
-
Inheritance (Is-Relationship):
The basic idea of this approach is that RAMSIS core facilities redefine the data layer (ORM) and enrich the mappings by means of inheriting both of the mapping and
PyQt5.QtCore.QObject
.
As a consequence:
- Mappings from
ramsis.datamodel
might still be independently used. - RAMSIS core facilities need to redefine (at least parts of) the data layer
- A common meta base class needs to be defined for the pyQT's
QObject
meta base and SQLAlchemy'sDeclarativeMeta
(see also: https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/api.html?highlight=declarative_base#sqlalchemy.ext.declarative.declarative_base) - RAMSIS core data layer objects would need to use an single table inheritance approach
-
Has-Relationship:
Data layer objects have a signal emitter attached (either a mock in case
pyQT
is not available) or apyQt
signal.
This approach implies that:
- The data layer does not need to be redefined.
- Also, there is no need to use concepts such as single table inheritance.
@heilukas, since you are more familiar with the concepts of pyQT
: Would you be so kind and give an example how you'd implement this approach? Does this example here describe the approach conceptionally?
Personally I'd rather would go for the second approach since it seems much easier to implement (less code, etc.), for the time being.