One more note:

I have an project where we are using in memory Models as the storage for
object data (i.e. all/most instance variables are stored in the model).  In
some cases we want to lock the model so that no further changes can occur
(specifically when we pass the model through a listener interface)  To do
this locking we have created a permissions implementation that prohibits
all changes to the model and pass that down.

In doing so we found several interesting corner cases where unanticipated
modification was occurring.

Claude

On Tue, Nov 14, 2017 at 12:12 AM, Adam Jacobs <jacobs_...@hotmail.com>
wrote:

> The subject of immutability was raised in JENA-1391 (
> https://issues.apache.org/jira/browse/JENA-1391).
>
> Specifically, the `getUnionModel` method in Jena 3.4 returns an immutable
> model view, and the implementation of the aforementioned story includes
> methods that will return an immutable dataset view.
>
> The question is whether these immutable views deserve their own
> interfaces. Currently, the views are returned using what I called
> "unexpected immutability" because they implement mutable interfaces. This
> introduces the potential for `UnsupportedOperationException`s.
>
> Unfortunately, that (degenerate) pattern is used in Java's `Collections`
> utility as well (https://docs.oracle.com/javase/8/docs/api/java/util/
> Collections.html) but Scala is a clean example to draw inspiration from:
> by implementing immutable interfaces as parents to their mutable
> counterparts (rather than vice verse) we can satisfy the Liskov
> Substitution Principle.
>
> Obviously, implementing that solution is easier to do from scratch than in
> an existing code base; but I imagine it could be done in multiple phases,
> by introducing the new interfaces and using them in new methods (with easy
> conversion to mutability via union) while gradually retrofitting older
> methods.
>
> The question then, is whether such a change is worthwhile...




-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to