Ofparameter vs ofxgui


Why is using ofParameter recommended over ofxGui directly?

As suggested here.

(I’ve never used ofParameter, only ofxGui, so I don’t know its advantages.)


Good question.
In my opinion, for a simple example the differences are negligible. But if your program grows, you probably would like to separate storage classes from gui (drawing) classes. Your ofParameters could have a lot more uses than just drawing a gui, e.g. using ofParameterGroup to make different groups over a single set of parameters for saving/loading to/from JSON, sending parameters to OSC or just being referenced in many other classes. In those cases, the cleanest option is to separate drawing from storage. And actually the syntax used is the same, only the declaration is different. So ofParameter seems to be a better option.


One of the best reason is that using ofParameters you could write classes that have their own ofParameterGroup parameters, add the ofParameter variables to them and then simply add the parameters member to the ofxPanel, saving much code in your ofApp.cpp.
Another good reason is that using the parameters this way will let you also switch between different gui addons that support ofParameter without rewriting much code.