pinToggle library - comments please

UKHeliBob:
I suspect that the problem with classes is that they look daunting and you have to know quite a lot before you can actually do anything. Most people just want to get on and do something, hence the "Hello World" and Blink programs. Then, of course, they continue along the same path adding complexity and by the time they ask for help they have invested time in their current flawed program and are often unwilling to throw it away and start again.

Perhaps part of the answer depends on the stage at which help is asked for. Someone asking for help on how to start a project may well be advised to use classes whereas somebody who has a working program with a problem might be helped further along their current path, albeit with advice to consider using classes.

The advantage I have is that most of these kids haven't even started with anyone's particular opinion of what are the basics; they just know they want to do something fun or cool. No one told them that any particular part is supposed to be advanced, so they don't know that they are supposed to be struggling. :wink:

The benefit that I believe I see is that they start to think about objects from the very beginning. They are never experiencing a paradigm shift in that regard.

If they want to program a button switch, they design a class. If they want another button... problem already solved. The first lesson we go through is turning on and off led13 using a button switch.

It also makes the understanding of Servo, Serial, LCD and other common libraries much easier to use/understand (and less onerous to investigate) because they understand what the dot operator actually does.

Finally, it makes functional programming easier to understand, I'm seeing them create fewer and fewer functions that take no arguments and return no values.

Once you understand classes (much like pointers) they are incredibly easy. Overcoming that obstacle earlier so far seems to make it all that much easier and fun.

Side Note: As you mention, once you have a hammer in your toolbox (classes) every problem becomes a nail, so now I'm teaching lambdas as procedural functions called from only one place. I admit it was challenging for me to learn the lambda syntax, but just like classes, the kids don't yet know that they are supposed to be difficult!!!