Closed juandent closed 6 years ago
the simplest is MVC + Services. For example: LoginPageController contains LoginPageView and has a reference to a storage. Storage is one for one database and defined in main
function (or a singleton if you don't care about unit-tests). Controller gets some data from a storage, next asks view to draw something that depends on this data. Next receives some user input and updates data. Storage service must know about data classes, it's ok. But data classes must not know about storage services/view/controllers cause there is no reason - data is passive. Controller contains logic and events handling. View has public functions like setUserNameLabelText(std::string)
and showErrorDialog(std::string message)
I understand. Would it be accurate to state:
Is this correct?
You have no idea how much you are helping here!!
Regards
view must not see the whole controller interface at least. To move implementation of user input from view to controller use either callbacks like std::function
or an abstract class (an interface) like ViewDelegate
which is inherited by controller and view must store a pointer/reference to it.
If model is active (it means has some kind of logic implemented) so it may be unseen for controller. But if model is just a struct with several fields and that's all so controller must operate with model and next ask view to refresh. You can view this architecture implemented in my mitsoko-template repo in Core dir
@juandent is the issue actual?
it is for now
Hi, It's me again, haha. I was wondering if you have a small sample where you keep the data access stuff (all that require initStorage()) separate from the model and view of the application. Or if you don't have a sample, maybe you can explain the architecture you use?
Best regards for a lovely library!!