2021-02-05 12:16 AM
Hi,
I though that I can save a lot of work by bypassing Presenter when fetching data from the Model, like this:
class FrontendApplication : public FrontendApplicationBase
{
public:
FrontendApplication(Model &m, FrontendHeap &heap);
virtual ~FrontendApplication() {}
//added this
Model& getModel()
{
return model;
}
...
Is there any problem with this approach, when fetching/setting Model data?
View <-> Presenter <-> Model
vs.
View <-> Model
If I use Presenter, I need to implement viewPresenter.cpp and viewPresenter.hpp for every single variable, which seems crazy amount of work, for seemingly 0 purpose.
I could just use application().getModel().getVariable(), right?
Thanks!
2021-02-09 12:16 AM
Hi,
TouchGFX follows the Model-View-Presenter design pattern (MVP) which is a "standard" pattern used for building User Interface applications. You are not wrong in bypassing the Presenter, I personally also avoid working with the presenter when i do quick tests/demo but I usually don't recommend it to prevent bad habits :grinning_face_with_sweat:.
The idea is to divide the code into parts with their own responsibility, the Presenter being in charge of the logic and the View of the visuals.
/Romain