Flowchart "for each" loop loop without variable increment

82.9k views Asked by At

I'm designed a flowchart to describe at a high level how a programming process works. Part of this process involves looping through a set of items. I'm wondering if there is any standard or semi-standard way of representing a "for each" style loop in a flow chart, that does not involve making the iteration explicit with an iteration box like m = m + 1 (e.g. here). Most modern programming languages have some kind of "for each" construct for enumerating a set or sequence of items, without having to think about indices. I'm basically looking for a similar visual construct for a flow chart, to avoid wasting space with an explicit counter increment.

6

There are 6 answers

0
FloverOwe On

The "bread-loaf" convention.

I prefer the "bread-loaf" convention, especially if one has to show lots of loops. Adjust wording as needed. I'm not sure if it's an official symbol anywhere, but it could be adopted as a shop convention regardless.

2
NateW On

Here's an example I found that seems pretty intuitive. I have no idea if this is a standard practice, but it looks good to me.

enter image description here

Sorry about the resolution. The important parts are that the parallelogram on the left says "Listof numbers", the diamond in the middle says "For each", the arrow going down and to the right of the diamond says "Each Number", and the arrow going straight down from the diamond says "End of list"

0
antonimmo On

I've done that by setting an initial variable N=numberOfItems, and the rest is history ;) (i.e. a conventional "for" loop).

0
Ray Hulha On

I had the same question and found the answer here.

enter image description here

1
user21715 On

Sooo I know this topic is now 3 years old, but it might help others. I found a little trick to represent a "for each" loop in a UML flowchart. I don't think it is standart, though I find it quite instinctive.

Here it is :

embedded process

0
Glorfindel On

Mendix is a rapid application development platform where most of the logic resides in so-called 'microflows', which are represented by flowcharts. Here is an example how it represents a 'for each' loop:

enter image description here

It's similar to @user21715's answer, but it uses the same 'parameter' pentagon which is also used to denote input parameters for a flow, with a 'loop' icon. The small gray circle is the end of the loop iteration (similar to continue in most languages); they have an orange one for a break (a premature end of the loop). The first and last statements in a loop are recognizable by having no incoming resp. outgoing arrow.