re: Hiding Complexity Does Not Make It Go Away, Or Does It? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Inventing your own type (with its own name and its own methods) makes code take longer to read because it is unfamiliar. In this particular case, I...
 

I totally agree with you. It is usually better to use data structures that are provided by the standard library instead of inventing your own unless you have strong reasons to do so. And in my case there is no strong reason.

I would probably not have done this in anything but a fun project. I did it for the sake of learning and having fun doing it. However I think that this is why having a powerful collection library is so important for me in a language. Because then you can conveniently pick the right datastructure for the job without having to "invent" it first.

I hear you when you say that index = (index + 1) % array.length is common and therefore easy to understand for (as you said) most developers. But that does not make it simpler than calling next on an iterator. That is actually the difference between simple and easy which I was refering to.

You are right that what I implemented was not really a circular list (which is an iterable) but an iterator on a circular list. The iterator has a state, pointing to the current element.

Thanks for commenting and pointing this out!

code of conduct - report abuse