I'm restarting this discussion and it could readily be part of a couple of others, including:
and programming - Classes and objects: how many and which file types do I actually need to use them? - Arduino Stack Exchange
because it seems to come up in a lot of different posts
I've also looked at a bunch of examples in github, etc. and then looking at the practicalities of developing a small but not trivial application that includes wifi, ntp time, a web server for the UI, config variables, hardware and communication access, logging, timers, and then the operational state machine.
It would be nice if there were in the tutorials, rather than scattered across this forum, stackoverflow, github, and very thick C++ tomes, about the best ways and the trade-offs for doing a somewhat sophisticated "sketch" on the arduino supported platforms. There are at least two issues here:
- What are the trade-offs of various approaches in general
2 Whether the arduino IDE is the best tool for doing the job.
The comments by Robbin and gfvalvo in the 588837.0 post set the tone. Hybrids are possible, and maybe preferred in some cases. Following gfvalvo, for example, takes one down the path more oriented toward classes and objects. (note: I'm no expert programmer here, so I may make incorrect assumptions, hence my request for a primer or tutorial on the matter). And that seems to be more work. For example, I have a web server in may main .ino file, and started out with all the route handling code in a routine in another file/tab. It worked. But it's not very clean. But when I convert to .cpp and .h. the .cpp file doesn't have the scope to know what is the server, and since it's not a class, I could try passing it to the function, but it would be cleaner to make the web module more or less stand alone. Then this creeps into how much encapsulation to do , variable passing, interfaces to hardware, minimizing global variables, etc. How does a class communicate with other classes, pass by reference, etc are all important topics. And then there are things like lambda functions that I really don't know what is involved. So a tutorial organized around these topics could probably help a lot of people And I'm certainly not the only one who is not exactly an experienced coder who is trying to do something more complicated than an example sketch.