Teaching when to use MyBlocks While mentoring a FIRST® LEGO® League team, I had a chance to show the kids (who are in an elementary school) how to use the My Block Builder tool while programming their LEGO® Mindstorms robots.


  A My Block is a combination of one or more blocks that are grouped into a single block. Once a My Block is created, you can use it in multiple programs.
  From: LEGO® Mindstorms EV3 Information


It's like defining an external function, but with blocks, and makes for great program shorteners (instead of having 20 or so blocks, 2 or three times, the students learn to make one single My Block, 2 or three times). 

However, the students seem to be forgetting, repeatedly, that this tool exists. Only when I point out "why not use a My Block, instead of copy-pasting a lot of blocks?", do they use the My Block tool. 

I'd like them to understand when they should use My Block, (and hopefully why, because it might give them insight on external functions later on, should they choose to study CS) without having me point out the tool. There are many use cases for My Block, so giving them a list of situations doesn't work (I've tried, to incredible failure).

What can I do to help the team members understand when they can and should use My Block?
Four relatively easy ideas would be to:


Conduct periodic code reviews where you point out style issues like these. If you make code reviews a regular thing, the repetition should hopefully help students eventually start using functions independently. Since your students are in elementary school, this should obviously be a very lightweight and informal code review.
Develop an automatic style checker for whatever language you're using to perform these sorts of style checks for them. (Hopefully, whatever language you're using is exportable into a text-based or otherwise structured format that actually does permit this sort of analysis.)
Heavily emphasize that if the students are at any point copying-and-pasting, they're doing something wrong. Make it clear that copying-and-pasting is a sin. (This is assuming whatever language you're using is actually usable enough to make this a truth rather then a lie.)
Give them a short style guide to follow; include a note about eliminating redundancy using functions/myblocks in the style guide. This will probably be more effective with older students.


If you have control over how students learn to code, a broader (and probably more effective) strategies would be to teach students how to use your MyBlocks/functions first and foremost, almost before anything else. 

That is, teach them the absolute bare minimum functionality to make something happen, then teach them how to decompose a large problem into smaller subtasks, and have them create a MyBlock for each subtask. I would do this first, before teaching them things like control flow, variables, etc... Basically, make the idea of "refactoring" and "identifying subproblems" one of your first lessons.

The hope is that if you make using functions/MyBlocks one of your very first lessons, they're less likely to pick up the bad habit of writing redundant code.