22
My kid asked why my code was so long and it made me stop
I was showing my eight-year-old a simple number guessing game I wrote in Python. It had about forty lines. She looked at it and said, 'Why is it so big? Can't you just tell the computer to guess?' I explained loops and conditionals, but her question stuck. I realized I was writing for other coders, not for the simplest idea. I rewrote it to just ten lines by using a while True loop and one if statement. Has anyone else had a simple question make you rethink a basic approach?
2 comments
Log in to join the discussion
Log In2 Comments
gracea191d ago
Ever read that thing about how kids ask the best questions because they don't know the "right" way to do stuff? Your story totally fits. It's so easy to add extra code just because it feels like the normal way to write it. Makes you wonder how much of our own work is just habit, right?
5
janab821d ago
Yeah, that part about writing code for other coders really hit me. I used to add extra checks and comments just because that's how I was taught. After reading @gracea19's point about habit, I see my old ten-line functions were often just three lines of actual work. The kid's question cuts right through all that.
4