loading...

re: What is the simplest code to explain a loop? VIEW POST

FULL DISCUSSION
 

If I would a teacher, I would forbid mentioning “for” and “collection” in one sentence - processing collections should be done with map, foreach, etc(I guess they are called a higher order functions?) and never with loops, where scope is unclear and intention is unclear. Loop can do map, reduce, filter, or all of them at the same time. “for” or “foreach” constructs that accept a code block with the scope of a calling code are just loops in disguise.

just my two opinionated cents on this matter ))

 

I'm actually planning to explain while-loop at first... then going into lists (no other collections), then mention how to iterate through that list using for, I guess it's very intuitive this way IMHO... what do you think?

The way map & foreach works in the functional manner is just JavaScript specific, creates more ambiguity, and actually the new way (ES6) got to be for of which is poorly intuitive :(

 

as many other things in CS loops for processing lists are intuitive and not the best choice in the end )

what I wanted to outline is that during education its very important to communicate that “this is not the solution”, but rather an introduction.

PS would be nice to come up with examples for all basic concepts without bringing other basic concepts - like loops without lists, recursion without tree data structure etc )))

"this is not the solution"

I really hate when I watch a "this is a demo" course, cuz most of them are like that, and I'm like: "So where the is the actual solution?". Ends with me inspecting github repos to see how it's actually implemented :D

Ah yeah... I totally agree about mentioning one concept totally alone.

We try to follow a strict manner in showing one thing at a time, while trying to mix things after the user gets the knack of that one principle alone.

what I ment is that you should outline that even with simplest building blocks like loops, beginner developer should question if its a good fit for their problem and seek for better )
I agree, with entry-level courses it might be tough to combine with keeping interest for the subject, so good luck!)

code of conduct - report abuse