Tuesday, August 19. 2008Implementing Iterators
Let's kickstart this blogpost by defining what an iterator actually is. According to wikipedia, an iterator is:
"an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation."A collection can pretty much be anything. The most obvious sources would be arrays, but other than that, iterations can be done over database resultsets, strings, datetime intervals, directories, file content and XML listings, to name a few. The real benefit of using a standard iterator implementation, is that every implemented iterator does its job obeying a standard interface. Whether said collection is a database resultset or a directory structure; it can be iterated using the same method names. And that's neat, because it will save us developers a trip to the manual on many occasions (... yeah it does... just admit it... ). Continue reading "Implementing Iterators" Sunday, July 27. 2008Dependency Injection and Zend Framework ControllersAmong the standard object oriented principles is favouring composition over inheritance, and there are plenty of design patterns that work along this line. However, one of the most useful day-to-day facets of the idea doesn't seem to get a lot of attention from PHP developers, namely dependency injection. The general idea is, that if your class depends on some other object, that object should be passed in rather than generated internally or retrieved via a global variable or singleton. Continue reading "Dependency Injection and Zend Framework Controllers"
Posted by Ian Barber
in planetphp
at
17:02
| Comments (7)
| Trackback (1)
Defined tags for this entry: dependency injection, design patterns, framework, mvc, use at will, zend framework
(Page 1 of 1, totaling 2 entries)
|
Blog
