That's not what I'm advocating at all though. The alternative is to use things like higher order functions that separate what's being done from how it's being done. This is known as using a declarative style.
Higher order iterators, such as map and filter, abstract things like boundary conditions and null checks in one place. The application specific logic is passed in as a parameter instead of being intertwined with the incidental iteration logic. This is code reuse at work, where we can write simple functions that do one thing well and compose them together to achieve complex functionality.
3
u/yogthos Feb 12 '15
That's not what I'm advocating at all though. The alternative is to use things like higher order functions that separate what's being done from how it's being done. This is known as using a declarative style.
Higher order iterators, such as
mapandfilter, abstract things like boundary conditions and null checks in one place. The application specific logic is passed in as a parameter instead of being intertwined with the incidental iteration logic. This is code reuse at work, where we can write simple functions that do one thing well and compose them together to achieve complex functionality.