Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Newsgroups: comp.lang.java.programmer Subject: Re: Why "lock" functionality is introduced for all the objects? Date: Wed, 29 Jun 2011 01:12:13 -0400 Organization: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Lines: 22 Message-ID: References: NNTP-Posting-Host: iGmuHcWtyc5pbaBTyNZhJQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: WinVN 0.99.12z (x86 32bit) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5765 On 28/06/2011 4:43 PM, BGB wrote: > yeah... > > they made every object lockable but not every object cloneable, where > one would think cloning would be generally a higher priority. If they'd been smarter about managing mutability to begin with (e.g. fields immutable by default, objects normally immutable) cloning would not be a priority at all. Sure, the boxed primitives and Strings are immutable, and that's about it. We've got mutable stuff out the wazoo, most of which probably shouldn't be -- java.util.Date, anyone? Not to mention java.awt.Point and friends. All those conundrums about whether Square should be a subclass of Rectangle, or Circle of Ellipse, go away if they aren't mutable. Then they clearly are subclasses. Mutable collections and arrays also make type reasoning more complicated and don't allow casting a List to a List as then you might add a non-Sub Super to the list. If the list wasn't mutable there'd be no problem casting a List to a List. I could go on...but I won't.