Date start = ;
Date end = ;
Iterator i = new DayIterator(start, end);
while (i.hasNext()) {
doSomething(i.next());
}
Your Papa Bear example iterates over a cube in a 3d array. Your Mama Bear example is some seriously broken date iteration code (so you change lastDay from within doSomething?). The Baby Bear is equally broken 'time period' iteration code.Writing self documenting code isn't about giving everything complete and proper names. It's about choosing comprehensible and trackable names. You introduce Mr. Joseph Harrison as such, but you may thereafter call him Joe.
BufferedInputStream bufferedInputStream = ... // bad, too formal
BufferedInputStream bis = ... // bad, too casual
BufferedInputStream stream = ... // ok
BufferedInputStream input = ... // good
The Baby Bear code's naming is a bit off too. Is it inclusive or exclusive? I would not be bothered if I saw: for (y=firstY; y<=lastY; y++) {
The letter 'y' is obvious (yy/mm/dd), and its scope is small.