Item 4: Avoid Creating Duplicate Objects

Principle 1:
Immutable classes should be static!
“An object can always be reused if it is immutable”

String s = new String(“Silly Billy”); // NO NO NO

String s = “No Longer a silly Billy”

Principle 2:
You get special cases where you can re-use the mutable object that will not be modified.

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Leave a Reply