IMHO, this is the best reply by far, and is a far more comprehensive reply than my kvetching about Scratch teaching bad coding habits. The kids I've helped who started coding on their own, not to mention the college freshouts I worked with, had some of the worst coding habits imaginable, and it proved very difficult to break them of it. Once someone starts hacking and actually gets code to do something, convincing them that good design and structure is really important becomes quite difficult.
Having said that, I'm unaware of any source for good coding design and structure instruction, apart from an experience programmer. Most of the coding examples online are dreadful. Sorry to be so negative, but there is a lot of very poorly conceived and structured code out there and more being produced every millisecond!
Now how do you teach kids to be good programmers? Beat me. Probably takes guidance from talented adult?
There is probably no substitute for mentoring, preferably mentoring from several different perspectives over time. I believe Steve Jobs said something to the extent of engineering/design being the intersection of sciences and the humanities. I used to think he was full of it, but I've appreciated that view more in recent years.
Part of the reason I think this is so difficult is because there are so many ways of coding a system to create a product or solution. What makes a system divided into logical components? Does a particular inheritance hierarchy make sense? What is easy for others to understand? What is easy to upgrade/maintain? Outside the realms of algorithmic efficiency and resource utilization, much of this is subjective and difficult to quantify.
For kids, I would say it makes sense to teach design and evaluation skills first. Lego sets come to mind. What makes a particular Lego set good? Perhaps the pieces have flexible application. Is the set too simple or too hard to build? Is the assembled set fun to play with? Or does it fall apart too easily (yes, in the distant past I owned a big set or two that was fragile and could fall into pieces far too easily). One can do this with any number of objects: tablet computer models, headlamps, cars, and so forth. What design choices resulted in which consequences?
On the coding side, I would focus on human readability. I have worked with people who enjoyed writing code that was super duper compact, but difficult for others to quickly understand. Simple things like following variable naming conventions, using proper indents, and adding comments often seem stupid to new coders, but they make a difference to people who have to maintain the code months or years down the line.
Finally, I think that it helps to introduce the intersection of hardware and software early on.
The machines that run the code are black boxes to most kids. Explaining memory, and how code objects are instantiated, referenced, and deleted, will give a better understanding of what happens when a computer program runs. While this doesn't have much impact for a kid writing small programs on a computer with 4 GB of RAM, it might make a difference in the future if that kid is many years down the line creating systems that run into resource constraints.