Saturday, May 7, 2011

How to make object immutable

taken from java site
  1. Don't provide "setter" methods — methods that modify fields or objects referred to by fields.
  2. Make all fields final and private.
  3. Don't allow subclasses to override methods. The simplest way to do this is to declare the class as final. A more sophisticated approach is to make the constructor private and construct instances in factory methods.
  4. If the instance fields include references to mutable objects, don't allow those objects to be changed:
    • Don't provide methods that modify the mutable objects.
    • Don't share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store

http://download.oracle.com/javase/tutorial/essential/concurrency/imstrat.html
http://www.javapractices.com/topic/TopicAction.do?Id=29
http://www.javaranch.com/journal/2003/04/immutable.htm

Saturday, December 1, 2007

For ANIME FREAKS

We have largest repository of animes and hentai for your viewing pleasure