As our experience with hybrids
and hexagonal architecture grows, some early choices made during the work on the Artifact links field (of the Artifact modal) appear to have been wrong.
- The
LinkFieldController
should be in Domain, not in UI adapter. The controller holds the most business logic. We tried making it return "presenter" objects (like PHP), which is why we set it in the UI adapter. In retrospect, it was a bad idea, it should only handle Domain objects and nothing else. The UI (here a hybrids component) receives it and calls its function to do its job. The UI can even wrap Domain objects into presenters, but the controller's job should be holding the logic and knowing about the operations (such as marking a link to be removed, adding and removing new links, retrieving parents, etc.).
- Memory adapters have been a mistake. There is no need to abstract away "holding objects in memory", it makes the code very complicated for no benefit. Instead, the
LinkFieldController
should hold things in memory. At submit time, it is easy to ask it for its memory contents and format them correctly for REST. This will simplify the whole controller a lot (way fewer constructor injections).
-
ArtifactLinkSelectorAutoCompleter
should not fetch items by itself. It should ask the host controller. The controller should know about all the async operations and deal with faults in a uniform manner. The autocompleter should be a simple UI component that calls the right controller functions and assigns the right properties on the HostElement, and that's it.
- The
ArtifactLinkListDuplicateRemover
should be in REST adapter, not in UI adapter.