I am a layman without any programming-like education but I spent the better part of my free time to get into programming bots for some games in first AutoIt and then C++. I was introduced to programming in a very procedural style only using free functions. A couple of weeks ago, my focus shifted from actually making these bots to understanding how professional programmers are structuring their programs and inevitably I came across OOP, Design Patterns, SOLID and most recently Clean Architecture.
I want to say beforehand that I know full-well that these techniques are most likely counter-productive for the tiny programs I write; however, I want to get to know them out of the interest of learning.
I am currently trying to split the program into smaller parts to stick to the SRP and I’m sort of trying to implement the idea(s) behind the Clean Architecture. Since it’s an incredibly smaller program than what Clean is targeted at and since I’m most likely the only one who will be working on it, I am not too strict with the separation into Controllers, Presenters, ViewModels, Views and so on – also I’m not planning to separate the program into different DLLs in order to have the GUI in a completely different place. However, I am fond of the idea to have GUI absolutely dependent on the (business-) logic whilst the logic doesn’t know about the GUI at all, thus I will treat the GUI-Module as if it was in a different project. However, the “crossing of the boundaries” is something I cannot, for the life of me, understand how to implement, especially if it was from an external DLL to the application.
Correct me if I’m wrong: There is a Controller which sends a request to the Interactor-Object which will deal with several Entities and eventually return a result to the Presenter which takes care of the changes in the GUI. Basically, my input calls a function that returns some value after working with the app. This function-call is put into the Interactor-Object in the style of the Command-Pattern. It implements some Boundary-Interface* which is made public. That’s necessary to build the Controller in the first place since it needs to know the signatures it can call. Therefore, that interface becomes the access-point for the external DLL to send requests to the application.
However, wouldn’t the Interactor need to get references to the Business-Entities and the Presenter/s on construction so it can interact with them? The Controller cannot pass them into the Interactor as it doesn’t know anything about the Entities, which means the Controller would have to call an already built concretion of the Interactor – how is that being done? In my mind, the Application would have to pass the concrete Interactor to the Controller which is forbidden as the “inner circles” are not supposed to know about the outer ones.
This brings me to the second part, crossing the boundary outwards: How does the Interactor pass the response to an outer circle without knowing about it? I could imagine this is some sort of Observer-Pattern as the application does provide the interface the Presenter/s will have to implement, so the interactor does know the signature of the Presenters. However, this would require the Presenters to register themselves to a concrete Interactor-object which ends up in the same question as above.
Thank you in advance – any input would be appreciated.
TL;DR: Where do you instantiate UseCases/Interactors and how do you access these concretions from outside?