Hacker News new | ask | show | jobs
by Wowfunhappy 2338 days ago
The kids in my class run into all sorts of standard programming problems.

Two girls was creating a program where multiple characters had a conversation. Each character paused a set amount of time before saying its next line, and because the pauses weren't timed correctly, the characters kept talking over each other.

We draw a timeline together so the students could understand what was going on. The kids realized that every time one character was adjusted, every other character's code needed updates to match, and that this would get increasingly complicated as more lines of dialogue were added.

We talked through adjustments that could be made to lower the complexity. I suggested that when one character finishes speaking, it should "broadcast" a signal that it's the next character's turn. I don't remember if they actually refactored it, but they understood the problem-space and tradeoff.