Answers.Body: <p>This is what happens when you put the cart before the horse.  The kids know syntax, but do not understand programming.  This is very common.  The kid see what they are trying to do as as commands in code when actually it is a series of tasks that need to be planned prior to sitting in front of a computer typing code.</p>
  
  <p>Get the kids away from the keyboard.  Lay out the tasks.  Build a flow chart or pseudo code.  Once the program is understood in the task setting (groups of things to be done) then start to code.  The My Blocks will make sense to them.   Programming in front of the keyboard will always lead to the problem you are having.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-08T19:04:35.913Z
Answers.Text: Welcome to [cseducators.se]! That's a good idea, Thanks.
Answers.UserDisplayName: ItamarG3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-08T18:18:38.887Z
Answers.LastActivityDate: 2017-08-08T19:04:13.700Z
Answers.LastEditDate: 2017-08-08T19:04:13.700Z
Answers.UserDisplayName: Garth Flint
Answers.Body: <p>You need to show them the value of the MyBlocks (procedures): easier to modify, easier to read.</p>
  
  <ol>
  <li><p>Get them to write a program that would need a procedure or cut and paste. 
  Then get them to make a small change. This will also be a small change to the code if they have made their own procedures, but a big change if they used cut and paste. Keep giving them these changes until they ask for a solution. Then use your teacher skills to remind them of the MyBlocks.</p></li>
  <li><p>Show them two programs: one with cut and paste, one with MyBlocks. Have them in teams some with one version some with the other. Get then to work out what it does. Time them. Them swap over with a different example. Discuss why the version with MyBlocks was easier/faster to read.</p></li>
  </ol>
  
  <p>I don't tend to focus on the memory saving aspect; memory is cheep, and early optimisation is a bad idea. “optimise for readability, and maintainability, (and big O, when they are older) let the compiler do the rest.”</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T21:05:56.453Z
Answers.Text: MyBlocks aren't like functions in that way. You need to reuse the tool for creating them if you want to make a change. That's why I didn't want much to do with the functions analogy, because it isn't such a good one. Also, what does "teaching skills" mean? Not quite sure I understand
Answers.UserDisplayName: ItamarG3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T21:16:09.607Z
Answers.Text: May be the kids are right, may be it is better not to use them. I said “teacher skills”, to mean that after that you carry on being a teacher, but it is outside the scope of the question. I would probably respond to the question with a question, to try to lead them to using the MyBlocks.
Answers.UserDisplayName: ctrl-alt-delor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-03T12:08:07.967Z
Answers.Text: Can you give an example of what kind of program would have this feature?  I don't understand what you're saying in this answer.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-03T12:29:26.270Z
Answers.Text: @BenI. If you cut and paste, then choose to change the code, then you have to change every copy.
Answers.UserDisplayName: ctrl-alt-delor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T21:04:18.477Z
Answers.LastActivityDate: 2017-08-08T09:20:15.600Z
Answers.LastEditDate: 2017-08-08T09:20:15.600Z
Answers.UserDisplayName: ctrl-alt-delor
Answers.Body: <p>Four relatively easy ideas would be to:</p>
  
  <ol>
  <li>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.</li>
  <li>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 <em>does</em> permit this sort of analysis.)</li>
  <li>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.)</li>
  <li>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.</li>
  </ol>
  
  <p>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. </p>
  
  <p>That is, teach them the absolute bare minimum functionality to make something happen, then teach them how to <em>decompose</em> 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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T20:14:00.430Z
Answers.Text: 1, 2 and 3 are superb. Really useful. (Might even make my regex skills better)
Answers.UserDisplayName: ItamarG3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T19:50:40.190Z
Answers.LastActivityDate: 2017-08-02T19:50:40.190Z
Answers.UserDisplayName: Michael0x2a
Body: <p>While mentoring a <a href="https://www.firstinspires.org/" rel="nofollow noreferrer" title="Information about FIRST®"><em>FIRST</em>®</a> <a href="http://www.firstlegoleague.org/about-fll" rel="nofollow noreferrer" title="Information about the FIRST® Lego® League">LEGO® League</a> team, I had a chance to show the kids (who are in an elementary school) how to use the <a href="http://ev3info.weebly.com/creating-my-blocks.html" rel="nofollow noreferrer" title="How to create a My Block">My Block Builder</a> tool while programming their <a href="https://www.lego.com/en-us/mindstorms" rel="nofollow noreferrer" title="Information about the LEGO® Mindstorms robots"><em>LEGO</em>® Mindstorms</a> robots.</p>
  
  <blockquote>
    <p>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.<br>
    <sub>From: <a href="http://ev3info.weebly.com/creating-my-blocks.html" rel="nofollow noreferrer" title="How to create a My Block">LEGO® Mindstorms EV3 Information</a></sub></p>
  </blockquote>
  
  <p>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 <em>My Block</em>, 2 or three times). </p>
  
  <p>However, the students seem to be forgetting, repeatedly, that this tool exists. Only when I point out "why not use a <em>My Block</em>, instead of copy-pasting a lot of blocks?", do they use the <em>My Block</em> tool. </p>
  
  <p>I'd like them to understand when they should use <em>My Block</em>, (and hopefully <em>why</em>, 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 <em>My Block</em>, so giving them a list of situations doesn't work (I've tried, to incredible failure).</p>
  
  <p>What can I do to help the team members understand when they can and should use <em>My Block</em>? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-02T20:59:40.667Z
Comments.Text: The link dose not go to a page that explains what a MyBlock is. I am assuming that it is just a way to define a your own block ( a procedure, what you ( and the C programming language ) are calling a function). But can you tell me what the distinction between external and not external.
Comments.UserDisplayName: ctrl-alt-delor
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-02T21:02:36.087Z
Comments.Text: @richard think of it as creating a DLL with one method in it, and then simply using that one method from the DLL, But not only once and more than one DLL. For that matter, external or not external doesn't really make a difference
Comments.UserDisplayName: ItamarG3
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-02T21:06:45.673Z
Comments.Text: You are creating small programs with <11year olds. And you want them to create multiple object files. And to see an advantage of this?
Comments.UserDisplayName: ctrl-alt-delor
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-02T21:07:56.420Z
Comments.Text: @richard it's really a bit much to explain in comments if you're not familiar with the software or with Lego Mindstorms
Comments.UserDisplayName: ItamarG3
Tags: <block-based-programming><lego-mindstorms>
Title: Teaching when to use MyBlocks
ThreadText: # Teaching when to use MyBlocks
  
  (Asked by: username_0 on 2017-08-02)
  
  While mentoring a [*FIRST*®](https://www.firstinspires.org/ "Information about FIRST®") [LEGO® League](http://www.firstlegoleague.org/about-fll "Information about the 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](http://ev3info.weebly.com/creating-my-blocks.html "How to create a My Block") tool while programming their [*LEGO*® Mindstorms](https://www.lego.com/en-us/mindstorms "Information about the LEGO® Mindstorms robots") 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](http://ev3info.weebly.com/creating-my-blocks.html "How to create a My Block")
  
  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*?
  
  **Tags:** block-based-programming, lego-mindstorms
  
  > **Comments:**
  > **username_1**: The link dose not go to a page that explains what a MyBlock is. I am assuming that it is just a way to define a your own block ( a procedure, what you ( and the C programming language ) are calling a function). But can you tell me what the distinction between external and not external.  
  > **username_0**: @richard think of it as creating a DLL with one method in it, and then simply using that one method from the DLL, But not only once and more than one DLL. For that matter, external or not external doesn't really make a difference  
  > **username_1**: You are creating small programs with <11year olds. And you want them to create multiple object files. And to see an advantage of this?  
  > **username_0**: @richard it's really a bit much to explain in comments if you're not familiar with the software or with Lego Mindstorms  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2017-08-02. Score: 2
  
  Four relatively easy ideas would be to:
  
  1. 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.
  2. 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.)
  3. 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.)
  4. 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.
  
  > **Comments:**
  > **username_0**: 1, 2 and 3 are superb. Really useful. (Might even make my regex skills better)  
  
  ---
  
  ### Answer by username_2 on 2017-08-08. Score: 1
  
  This is what happens when you put the cart before the horse. The kids know syntax, but do not understand programming. This is very common. The kid see what they are trying to do as as commands in code when actually it is a series of tasks that need to be planned prior to sitting in front of a computer typing code.
  
  Get the kids away from the keyboard. Lay out the tasks. Build a flow chart or pseudo code. Once the program is understood in the task setting (groups of things to be done) then start to code. The My Blocks will make sense to them. Programming in front of the keyboard will always lead to the problem you are having.
  
  > **Comments:**
  > **username_0**: Welcome to [cseducators.se]! That's a good idea, Thanks.  
  
  ---
  
  ### Answer by username_1 on 2017-08-02. Score: 0
  
  You need to show them the value of the MyBlocks (procedures): easier to modify, easier to read.
  
  1. Get them to write a program that would need a procedure or cut and paste.
     Then get them to make a small change. This will also be a small change to the code if they have made their own procedures, but a big change if they used cut and paste. Keep giving them these changes until they ask for a solution. Then use your teacher skills to remind them of the MyBlocks.
  2. Show them two programs: one with cut and paste, one with MyBlocks. Have them in teams some with one version some with the other. Get then to work out what it does. Time them. Them swap over with a different example. Discuss why the version with MyBlocks was easier/faster to read.
  
  I don't tend to focus on the memory saving aspect; memory is cheep, and early optimisation is a bad idea. “optimise for readability, and maintainability, (and big O, when they are older) let the compiler do the rest.”
  
  > **Comments:**
  > **username_0**: MyBlocks aren't like functions in that way. You need to reuse the tool for creating them if you want to make a change. That's why I didn't want much to do with the functions analogy, because it isn't such a good one. Also, what does "teaching skills" mean? Not quite sure I understand  
  > **username_1**: May be the kids are right, may be it is better not to use them. I said “teacher skills”, to mean that after that you carry on being a teacher, but it is outside the scope of the question. I would probably respond to the question with a question, to try to lead them to using the MyBlocks.  
  > **username_3**: Can you give an example of what kind of program would have this feature?  I don't understand what you're saying in this answer.  
  > **username_1**: @BenI. If you cut and paste, then choose to change the code, then you have to change every copy.  
  
  ---
  
  