IWS_WS24_clean_architecture/src/use_cases/README.md

1.9 KiB

USE CASES

"The software in the use cases layer contains application-specific business rules. It encapsulates and implements all of the use cases of the system. These use cases orchestrate the flow of data to and from the entities, and direct those entities to use their Critical Business Rules to achieve the goals of the use case. We do not expect changes in this layer to affect the entities. We also do not expect this layer to be affected by changes to externalities such as the database, the UI, or any of the common frameworks. The use cases layer is isolated from such concerns. We do, however, expect that changes to the operation of the application will affect the use cases and, therefore, the software in this layer. If the details of a use case change, then some code in this layer will certainly be affected." -- Robert C. Martin, Clean Architecture

Aufgabe

Anforderungen:

Interfaces:

  • CreateUserInputPort: Dieses Interface wird durch die execute methode des UseCases implementiert. Dadurch wird der Controller unabhängig von Änderungen im UseCase. Überlege dir welche Daten das UseCase als Input bekommt und definiere ein passendes Interface.
  • CreateUserOutputPort: Dieses Interface wird vom UseCase verwendet um Daten auszugeben. Es wird durch die present methode des Presenters implementiert. Dadurch wird das UseCase unabhängig vom Presenter. Überlege dir welche daten das UseCase zurück gibt und definiere ein passendes Interface.
  • IUserRepository: Dieses Interface wird vom UseCase verwendet um Daten aus der Datenbank zu holen. Dadurch wird das UseCase unabhängig von Datenbanken. Überlege dir welche Queries ausgeführt werden müssen und definiere ein passendes Interface.

UseCase

Implementiere einen UseCase zum Erstellen eines Users. Das UseCase sollte den CreateUserInputPort implementieren, das IUserRepository verwenden um mit der Datenbank zu kommunizieren und den CreateUserOutputPort verwenden um Daten auszugeben.