Possible Duplicate:
Mutable vs immutable objects
I understand the pros and cons between Immutable object vs Mutable object, but how do you decide which one to go for when you come to design it.
The reason why I ask about it is because if it's mutable, you can reuse the object by just changing object back to the initial state as being efficient and in an economical way, so when you deal with multistep operations you can just reuse it over and over again. Whereas Immutable object performance is magnified when you perform a multistep operation since it generates a new object at every step. <- As far as memory is concern
Here's the example:
//Mutable
A a = new A();
for(int j = 0 ; j < 1000 ; j++){
a.setP1(j);
//do something
}
//Immutable
for(int j = 0 ; j < 1000 ; j++){
A a = new A(j);
//do something
}
I know immutable objects are thead-safe, no synchronization required, simple, and share internals, but is there any particular reasons beside these ? and when should we make our class to final (immutable) ?