How to avoid getters and setters
I have read in many places that "getters and setters are evil". And I understood why so. But I don't know how to avoid them completely. Say Item is a class that has information about item name, qty, price etc... and ItemList is a class, which has a list of Items. To find the grand total: int grandTotal() { int total = 0; for (Item item: itemList) total += item.getPrice(); return total; } In the above case, how does one avoid getPrice()? The Item class provides getName, setName, etc.... How do I avoid them? Jonathan Fingland When should you use getters and setters? Getters and setters are great