Describe what a collection contains where it is defined, not what kind of collection it is. It will save looking at the code.
Bad
private Map map = new HashMap();
:
:
Collection c = (new Order()).findByCriteria(criteria);
for (Iterator i=c.iterator(); i.hasNext(); )
{
Order item = (Order)i.next();
item.calculateTotal();
item.save();
:
:
Better to read:
// [String filename] => FileData
private Map parsedFiles = new HashMap();
:
:
Collection orders = (new Order()).findByCriteria(criteria);
for (Iterator i=orders.iterator(); i.hasNext(); )
{
Order order = (Order)i.next();
order.calculateTotal();
order.save();
:
:
Tip: It is recommended to use 'i' for the iterator name, especially when the collection is named appropriately. “orderIterator” would be excessively wordy, and 'i' is a widely embraced name to use for the iterator variable in many languages. Or if a Java 1.5 delivery is permitted, dispense with the iterator altogether and use a generic loop (see the [java15] chapter).