This is not something easy to do in Java, but in Ruby it's solved, more or less, by letting arrays and other collections have methods that accept a code block and execute it for each item in a collection.
Taken literally, Demeter says that iterating over a collection and doing something to each item is wrong.
Originally posted by Stan James:
Does forAllDo() just push this (maybe) "wrong" thing into a library where you can ignore it?
Originally posted by Frank Carver:
As pointed out above. Designing an abstraction from scratch (and typically in isolation) often leads to a kind of "minimalist but complete" solution which might be clumsy for real world use but contains very little duplication.
Similarly, Designing from real requirements (be it TDD or any other similar approach) often leads to a friendly but internally messy and duplicated solution.