Skip to content

Application: Alternative design for Interactors #67

Open
@lhaze

Description

@lhaze

Current implementations of Interactor pattern (#4, #51) has several flaws to consider:

  1. It uses hook methods (like Django's CBV) which may end up in a hook hell when your code flow gets more complex
  2. It promotes writing more complex code flow when you have to do something non-trivial, i.e. different handling of errors got from different parts of the business logic flow.
  3. Closely couples calling the interactor with the process of gathering input which might not always be the case, i.e. heartbeat-driven interactions with gathering data being part of the interactions and not the calling process.
  4. It presumes that there is a single source of input, represented by the InputPort and RequestModel. Doesn't generalize enough about sources of data, i.e. a model got from a database repository is treated differently than the data got from request.
  5. It doesn't promote actual modeling of the InputPort: a generic interface of the RequestModel doesn't have such nice dataclass features as domain objects got from any Repository.
  6. Separation of validation and actual processing might be somewhat artificial. There's no fundamental difference between validation errors (i.e. this id is invalid) and business process errors (i.e. this item is in an invalid state).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions