In a “clean architecture”, interactors (use cases) are responsible for defining the logic of business processes. Most examples define use cases this way:
public MyUseCase() {
public boolean execute(...) {
int id = repository.insert(a)
if(id > 0) {
b.aId= id;
repository.insert(b);
...
}
}
}
The interaction uses mostly simple CRUD operations or queries in the repository. The above example is synchronous for simplicity, but you can find repositions with the same approach using asynchronous solutions like callbacks or rxjava.
But what about a random case. For example, you cannot be 100% sure that after insertion ait will still be there when you enter b. What to do if after insertion ayou get some RepositoryException on insertion b.
, , , :
?