I am trying to refactor my project to match the Clean Code Architecture by Robert C. Martin Clean Code Architecture.
What is the best practice to use multiple gateways which depend on another gateway. Since all the instantiation should be done in an outer layer or the same layer, how should gateways communicate with other gateways?
- Shouldn't we use multiple gateways at all?
- Should the External System instantiate all gateways, work with them and just pass the first one to the use case?
- Should the main just instantiate the first gateway and pass it to the use case, so every other gateway is instantiated by the gateways itself?
This is an example from my code:
mainfunction which belongs to the External System and is the starting point.DashVisualizerwhich plots a Plotly Dash Application and therefore is also an External System- Bunch of STL files as a
Repository, so it's also an External System BuildJobclass which is an EntityPartclass which is also an Entity
So far everything is straight forward. The following is my attempt to categorize the transitive gateways and use case.
- I have an
STLFilesFinderclass which searches for every STL file in the repository and creates a Dictionary of them. I assume it's agateway. - Then I have a
PartLoaderwhich takes that Dictionary fromSTLFilesFinderand converts it toPartEntities. I don't want theSTLFilesFinderto do that because it has already too much code in the class. So This must be also agateway. - Last but not least I have the
BuildJobLoaderwhich takes all thePartentities and creates aBuild JobEntities. This is also a gateway. To be clear: a Build Job consist of multiple Parts.
The Main functions has the configurations and creates every instance of these gateways and passes the output to the next gateway. The result (a dictionary) and the DashVisualizer object is passed to the BuildJobVisualizer (use case).
Aucun commentaire:
Enregistrer un commentaire