Question: Calling expert Scala developers! Let's say you have a large object representing a writable data store. Are you comfortable with this common Java-like approach:

```
val complexModel = new ComplexModel()
complexModel.modify()
complexModel.access(...)

```

Or do you prefer:

```
val newComplexModel = complexModel.withADifference
newComplexModel.access(...)

```

If you prefer that, and you have a client accessing the model, how is the client going
to know to point to newComplexModel rather than complexModel? From the user's perspective
you have a mutable data store. How do you reconcile that perspective with Scala's emphasis
on immutability?

How about this:

```
var complexModel = new ComplexModel()
complexModel = complexModel.withADifference
complexModel.access(...)

```

This seems a bit like the first approach, except that it seems the code inside withADifference is going to have to do more work than the code inside modify(), because it has to create a whole new complex data object rather than modifying the existing one. (Do *you* run into this problem of having to do more work in trying to preserve
immutability?) Also, you now have a var with a large scope.

How would you decide on the best strategy? Are there exceptions to the strategy you would choose?

Answer: 
The canonical answer to your question is using [Zipper](http://en.wikipedia.org/wiki/Zipper_%28data_structure%29), one SO [question about it](https://stackoverflow.com/questions/380438/what-is-the-zipper-data-structure-and-should-i-be-using-it). 

The only implementation for Scala I know of is in [ScalaZ](http://code.google.com/p/scalaz/).
Immutability is merely a useful tool, not dogma. Situations will arise where the cost and inconvenience of immutability outweigh its usefulness.

The size of a `ComplexModel` may make it so that creating a modified copy is sufficiently expensive in terms of memory and/or CPU that a mutable model is more practical.