Item 1: Consider Providing static (factory) methods instead of constructors


  1. Unlike constructors they have names
  2. Static factory unlike constructors do not require creation of a new object
  3. Static factory can return an object of any subtype of their return type


  1. Main disadvantage is that classes without public or protected constructors cannot be subclassed. (A subclass is a class which inherits a method or methods from a superclass)
  2. Static methods are not readibly distinguishable from other static methods (do not stand out like constructors in documentation and outside the norm)
Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Leave a Reply