One of the advice given by Joshua Bloch is that, class should be designed as immutable.
I have the following class
public class Dividend {
public Dividend setDate(SimpleDate date) {
Dividend dividend = new Dividend(this.getStock(), this.getAmount(), date);
return dividend;
}
.....// More to go.
For setDate method, this object will not be modified.
Instead, a clone copy of this with its date field being modified will be returned.
However, by judging from the method name, how does the user will know this object will still remain immutable?
Is there a better naming convention besides setDate?