10 Reasons We Need Java 3.0
Subject:   get rid of public constructors
Date:   2002-08-06 16:28:49
From:   friendless
I would like to see constructors all be private, so that you have to invoke a static factory method to get a new instance of anything. The problem with public constructors is that as soon as you call "new", memory is allocated, even if an identical object already exists. For immutable classes, such as Integer and String, arbitrary amounts of memory can be wasted by useless creation of duplicate instances. By making constructors private, use of memory by a class is controlled by the implementors of that class, who understand it best in any case.

1 to 2 of 2
1 to 2 of 2