Do we ever need to prefer constructors over static factory methods? If so, when?
问题 I have been reading Effective Java by Joshua Bloch and so far it really lives up to its reputation. The very first item makes a convincing case for static factory methods over constructors . So much that I began to question the validity of the good old constructors :). The advantages/disadvantages from the book are summarized below: Advantages: They have names! We have total instance control (Singletons, performance, etc.) They can return a subtype/interface Compiler can provide type