Interesting, because as a former CS teacher I regularly did this. We'd go through some material and then I'd demonstrate it being used in different contexts, sometimes writing code that wouldn't work and sometimes writing poor code (while loops that should be for loops, inconsistent variable names, etc...) and the kids dug pulling it apart. It's much easier to critique than to create when you're beginning coding.
On that note I've been giving a lot of thought lately on how to develop curriculum which does a better job of teaching coding skills without necessarily needing code. Design thinking, but at a smaller scale, and later translatable to beginner level problem solving. Where kids get hung up is they often don't have a toolkit for this type of thinking, and building that up, while still making it interesting, is a challenge.
On that note I've been giving a lot of thought lately on how to develop curriculum which does a better job of teaching coding skills without necessarily needing code. Design thinking, but at a smaller scale, and later translatable to beginner level problem solving. Where kids get hung up is they often don't have a toolkit for this type of thinking, and building that up, while still making it interesting, is a challenge.