# What kind of design is comparable to these programming concepts?

I understand this may sound like a weird question, but bear with me here, OK?

I'm getting ready to teach some kids introductory computer programming. We're going to use Scratch, a drag-and-drop "brick-based" language designed by MIT.

Now, scripts in Scratch are comparable to LEGO structures. Each script needs a base, and pieces to build it up. So far, so good.

However, scripts can also contain conditionals and loops, both of which accept a sub-structure.

I would like to show my students a LEGO structure that is comparable to a Scratch script. How could i do something like conditionals and loops?

A conditional can perhaps be represented by a door that can be blocked from the other side, or maybe two doors, of which only one is blocked via a sliding brick.

As for loops, I would represent them as conditionals with counters, by blocking a door with a set number of bricks and removing one brick per iteration. If you'd rather count upwards, then a fixed size hole can be filled with bricks gradually.

These analogies were made to the "minifig walking through a set of corridors - the program" analogy, but we could surely find solutions for axles and gears or even pneumatics if you were thinking along those lines.

• I was thinking more along the lines of "this building is like a script", but your ideas seem to work with that as well. Oct 22, 2014 at 19:37
• @Scimonster If the answer was useful for you, please consider accepting it, unless there is some information you still wait for, in which case I'll be happy to amend it. Oct 31, 2014 at 10:49
• I'm just waiting to verify that this works. I will be holding the class next week, and will try it out then. Oct 31, 2014 at 10:50
• In the end the kids were able to understand without the LEGOs, but you had a good method anyways. I might use it next time. :) Nov 5, 2014 at 15:18

Based on the image on the Scratch home page, I would simply wrap the substructure in a single color, which represents the loop.

For example:

`````` ______
|_Loop_|__
|__|__s1__|
|__|__s2__|
|__|__s3__|
|______|
``````

If that makes sense.

• While that indeed works visually, i'm not sure it conveys the message of a loop. Oct 22, 2014 at 19:55