Is the a pattern for iterating over lists held by a class (dynamicly typed OO languages)
Posted
by Roman A. Taycher
on Stack Overflow
See other posts from Stack Overflow
or by Roman A. Taycher
Published on 2010-06-05T12:12:16Z
Indexed on
2010/06/05
12:22 UTC
Read the original article
Hit count: 242
If I have a class that holds one or several lists is it better to allow other classes to fetch those lists(with a getter) or to implement a doXList/eachXList type method for that list that take a function and call that function on each element of the list contained by that object. I wrote a program that did a ton of this and I hated passing around all these lists sometimes with method in class a calling method in class B to return lists contained in class C, B contains a C or multiple C's (note question is about dynamically typed OO languages languages like ruby or smalltalk)
ex. (that came up in my program) on a Person class containing scheduling preferences and a scheduler class needing to access them.
© Stack Overflow or respective owner