Iterator Design Pattern Questions

I was recently shown the PHP SPL libraries and decided to check ‘em out. First thing that caught my attention - all the iterators. Read up a bit and find out that that is the first design pattern the authors decided to tackle - so it makes sense that there are so many of them.

Since I know very little about design patterns I decided to do some research on this particular one (mostly reading the articles provided at the bottom of the SPL Doc page - though I did also read over some books again). Understand what they are and how they are used and where they are used. What I don’t get is the simple - why they are used. Why should I have the extra levels of abstraction needed to implement them? Why should I want all my loops to look the same?

I understand the concepts of encapsulation and modularity - but at what point is enough abstraction enough? Does it have to do with the size of a application or size of the team building the application? Or is it simply to standardize the method used? If so - why does the method need to be standardized? Efficency, optimization, readability, reuse, elegance (someone please define that by the way), robustness (another definition I would like to have), style - any one or all of the above?

I can use the classes and regurgitate everything I read - but I’m still lost for why?

del.icio.us:Iterator Design Pattern Questions  digg:Iterator Design Pattern Questions  furl:Iterator Design Pattern Questions  reddit:Iterator Design Pattern Questions

Leave a Reply