tag:blogger.com,1999:blog-4035567729001522718.post1740608582355067662..comments2022-10-02T04:30:17.851+05:30Comments on Char Sequence: Data immutability in JavaShantanu Kumarhttp://www.blogger.com/profile/05850495396182844220noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-4035567729001522718.post-36243275093518700772010-02-14T00:34:03.198+05:302010-02-14T00:34:03.198+05:30@Peter That's right - AtomicReference does a b...@Peter That's right - AtomicReference does a better job. I have removed the Mutable abstraction entirely.Shantanu Kumarhttps://www.blogger.com/profile/05850495396182844220noreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-36417688579763213612010-02-13T22:06:05.486+05:302010-02-13T22:06:05.486+05:30Hi shantuna,
i havent encountered problems caused...Hi shantuna,<br /><br />i havent encountered problems caused by the lack of final local variables, so i don't like to pay for something that has not caused problems on systems i have been working on. But i guess it is a matter of taste.<br /><br />About the fixes, there still is a problem with the hash and tostring.<br /><br />The whole class can be dropped i think, check the atomicreference for a more powerful alternative.pveentjerhttps://www.blogger.com/profile/17847641595368096163noreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-90747321744540753572010-02-13T06:09:35.694+05:302010-02-13T06:09:35.694+05:30@Peter All three of your points are valid - I have...@Peter All three of your points are valid - I have updated the post. Thanks! However, I feel the clutter issue is a matter of perspective and getting used to.Shantanu Kumarhttps://www.blogger.com/profile/05850495396182844220noreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-78693465511616006192010-02-13T02:09:11.874+05:302010-02-13T02:09:11.874+05:30I see à few problems with your post.
Declaring lo...I see à few problems with your post.<br /><br />Declaring local variables final has nothing to do with concurrency control since stackframes (the container where local variables are stored). Personally i find final local variables causing a lot of syntactic clutter). So i almost never use them.<br /><br />There is à race problem in your mutable class in the equals method. It could be that the value is set to null by another thread after the if check on value is null.<br /><br />Also your tostring and hashcode are potential victems of npe'spveentjerhttps://www.blogger.com/profile/17847641595368096163noreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-79574183435556375492010-02-12T19:10:46.601+05:302010-02-12T19:10:46.601+05:30@Tony I have noticed Functional Java and I agree, ...@Tony I have noticed Functional Java and I agree, I wish Java as a language could allow more.<br /><br />@Alex Clojure is simply awesome! But as long as we are in Java... :-)Shantanu Kumarhttps://www.blogger.com/profile/05850495396182844220noreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-2781691316782725082010-02-12T18:10:29.405+05:302010-02-12T18:10:29.405+05:30Or just use a language where you start from immuta...Or just use a language where you start from immutability, like Clojure.... :)Alex Millerhttp://tech.puredanger.comnoreply@blogger.comtag:blogger.com,1999:blog-4035567729001522718.post-6689556800376795002010-02-12T16:55:37.088+05:302010-02-12T16:55:37.088+05:30You might be interested in Functional Java, which ...You might be interested in Functional Java, which takes this thesis as far as Java allows (which is not very far in the greater picture).Tony Morrishttps://www.blogger.com/profile/17206456907461293947noreply@blogger.com