On Sep 27, 2005, at 11:49 AM, Jim Freeze wrote: > This may be a silly design question, but I always balk at > the right answer when I am confronted with it. I don't think this is a silly question at all. I'm having to deal with it myself right now. I never seem to come up with the same answer twice in a row. [snip] > In other words, for classes that manage a list of items, > do people prefer to see a custom iterator, such as #each_<item>, > or do they prefer getting back an array and iterating > over it themselves, such as #<items>.each? > > Pea.new.each_pod { |pod| ..do stuff.. } > Pea.new.pods.each { |pod| ..do stuff.. } > There is another possibility, have the pods accessor return a (shallow) copy of the original. I've done all three. These days I just return the array and let the user do what they want. This saves me a lot of work at the risk of potentially ruining the integrity of the object structure. Seemed like a good idea at the time, but putting it that way... :-) Actually I don't think it is that bad. If I was worried, I'd return a copy. I don't think I'd go the each_pod route. Who knows what I'm going to think tomorrow. Cheers, Bob > Cheers > -- > Jim Freeze > > ---- Bob Hutchison -- blogs at <http://www.recursive.ca/hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/>