In the object world which method is best for milking a cow?
Index In the real world, the farmer milks a milking cow. In the object world, the milking cow offers up a milk method that creates a transaction recording how much milk was delivered to the farmer. There are two possibilities for the milk method in the MilkingCow class: public MilkingTransaction milk(long millilitersRequested){ … } or public MilkingTransaction milk(long millilitersRequested, Farmer aFarmer){ … } The second choice is what we prefer. The cow’s milk service creates the transaction because an old cow may have not be able to crank out milliliters requested. So the cow knows its limits of production and can validate milliliters requested better than the farmer. If the milliliters requested is too much then an exception can be thrown. The farmer is also a parameter because the transaction should not be created if the farmer does not have the proper privileges to milk the cow. In our methodology we localize all the testing rules in the services involved in adding collabora