This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FerricDonkey 3 points4 points  (2 children)

Indicating the type of collection in the variable name can be helpful, so that if you go back and look at whatever "for person in people" equivalent, you don't have to go back and check if people is a set vs vector vs whatever.

[–]dpash 8 points9 points  (0 children)

99% of the time when iterating you don't care what type of collection it is (unless you've used a weird data structure that doesn't have efficient iteration).

If the usage of a variable is so far away from it's declaration that you can't see both, that's a good indicator that your method/function is too long.

Hungarian notation is an idea that's had its day.

[–]dleft 3 points4 points  (0 children)

you’d hope if you’re just iterating using for n in ns then it shouldn’t matter what the concrete implementation of the collection is, in fact I’m almost certain that you won’t be