Comment Re:Another pompous "expert"? (Score 1) 211
You are confusing accessibility with responsibility. Using the money example, it is better to have the Money class increase the amount instead of having someone else do it. As in your example, Money.increaseBy(float), or even Money.add(Money), is more maintainable than orderTotal += Money.getAmount().
It's perfectly fine to have a Money.getAmount() : float, but do not have a Money.setAmount(float). If you need to set the amount, create a new Money object, new Money(float).
If you want a universal way of getting the value of money, then do Money.getAmount() : String. Not only does it allow you to display it, but it hides the underlying implementation.
It's perfectly fine to have a Money.getAmount() : float, but do not have a Money.setAmount(float). If you need to set the amount, create a new Money object, new Money(float).
If you want a universal way of getting the value of money, then do Money.getAmount() : String. Not only does it allow you to display it, but it hides the underlying implementation.