cancel
Showing results for 
Search instead for 
Did you mean: 

Why not bypass Presenter when fetching data from Model?

Tuoman
Senior II

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!

1 REPLY 1
Romain DIELEMAN
ST Employee

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 ��.

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