5 ms·
Sure, my point is don't attach the word "pattern" to the end and don't call it a "design pattern" You're just iterating through a list and calling it "iteratin
by neonological 6y ago
Sure, my point is don't attach the word "pattern" to the end and don't call it a "design pattern"
You're just iterating through a list and calling it "iterating" is perfectly fine.
Don't get me wrong. Naming things to abstract away complexity is perfectly fine and a foundational aspect of the English language.
Naming something the "iterator pattern" and calling it a concept within the sub field of "Design patterns" is the snobbery I'm referring to.
- xapata 6y agoThe iterator pattern is the use of an object or closure to encapsulate the state of the iteration. This is distinct from using a loop induction variable in the same scope as the loop block itself. In a language like C, which doesn't provide iterators by default, it seems reasonable to call that a design pattern.
- neonological 6y agoIt seems more reasonable to say you're iterating through a collection. It also seems more reasonable to just leave it as a programming technique rather then give it artificial weight and call it some bloated unnecessary academic term "design pattern"
- xapata 6y agoOk, call it the iterator technique, but there's a difference between using the iterator technique and iterating, which you seem to be refusing to acknowledge.
- neonological 6y agoNo actually I'm not completely grasping your argument. You described iteration earlier but I don't see any distinction with any definition of iteration I know of. I'm guessing your talking about how iteration is implemented versus the action of iteration. Both are one in the same.
- xapata 6y agoUsing a loop induction variable is a form of iteration over the elements of a sequence, but it is not using an iterator (technique, pattern, or whatever you want to call it). https://en.wikipedia.org/wiki/Induction_variable https://en.wikipedia.org/wiki/Induction_variable Heck, originally, looping was performed by physically looping your instruction tape, and a break was pausing the machine to physically break the tape. Talk about a fragile design pattern! The implementation matters. That's why people suggest using the iterator technique. It's not the best strategy for all cases, but it's generally better practice.
- neonological 6y agoThe index of a variable functions as an iterator for the iterator pattern. It still applies. There's not distinction here. But my point is also more general it doesn't apply to just iterators.
- xapata 6y agoScope matters. The purpose of the iterator is to encapsulate the state. An induction variable is not an iterator. A physical loop of tape is not an iterator. I'm starting to doubt your general point, because the specific isn't holding. Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics.
- neonological 6y ago>I'm starting to doubt your general point, because the specific isn't holding. A Very unwise and illogical notion to hold. We're addressing a very informal corner of CS that could be ripe with exceptions. Additionally the English language itself is full of grammatical inconsistencies so a single thing not holding does not disprove a generality. >Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics There's a contrast but nothing says this encapsulated state can't be an index itself. Meaning you can use indexes to implement iterators. As for the other point. The distinction between iterator and iteration. I still don't see it other than the fact that an iterator is used for iteration. From this page: https://en.wikipedia.org/wiki/Iteration https://en.wikipedia.org/wiki/Iteration "In Object-oriented programming, an iterator is an object that ensures iteration is executed in the same way for a range of different data structures, saving time and effort in later coding attempts. In particular, an iterator allows one to repeat the same kind of operation at each node of such a data structure, often in some pre-defined order. " Either way this is really an argument on semantics for a very narrow topic. The context is greater in scope and is about design patterns in general which I'm sure you'll agree doesn't encounter controversial collisions in meaning like iterator vs. iteration.
- dwaite 6y agoIf you say you are iterating through a collection using a while loop and not an iterator, then you are confusing people by using the wrong word for things. Design patterns is a formalism behind common patterns in software, and part of that formalism is that they are named. Obviously you don't need all that formalism every time you talk about patterns, the same way you don't talk about the laws of arithmetic every time you do math.
- neonological 6y agoExactly math doesn’t call informal but repeatable techniques “design patterns,” and publish a book about it. why should programmers make a misguided claim that these same techniques are also formal and give it a pretentious name. Design patterns is a unique phenomenon in programming. No other field is pretentious enough to refer to domain specific vocabulary as design patterns.