Functional Decomposition for Kids
My 8 year old is starting to learn coding and was working on a program that would use the graphics turtle to draw a happy face. It was pretty simple and had a square face, square eyes and a square nose. I showed him how to copy and paste the code for the first eye to simplify drawing the second eye. Later he told me how he had to copy the code and paste again to draw the nose. I recognized an opportunity to teach him about creating functions so I walked him through creating a function to draw a square with a parameter for the length of each side. We replaced the existing 8 or 9 lines of code with the single call to the function and successfully tested the new function.
He then turned to me and said, “If I press undo lots of times can I get back to the code without the function?”
I replied, “Yes you can do that, but why would you want to do that?”
He responded, “Because it looks like I did more work this way.”