The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

252991 (4) [Avatar] Offline
Dear authors,

This is regarding the following sentences in section 3.2.1

- Mutability is represented by any variable or field that is not stable or final...
- Fields should be final so that the compiler can enforce Immutability

I think using the final keyword is language dependent. For example in Java if a field is of type collection then even if it is declared as final, the collection can still be changed.

Maybe this can be reformulated, using language agnostic terminology.

Roland Kuhn (17) [Avatar] Offline
The point of mutable containers is discussed later on, so that should be covered. You are right that that sentence is formulated for a Java context, but it should be clear what is meant—I strongly suspect that C++ developers will translate final to const while reading it. Changing the book it no longer possible at this point, it is already in print.
252991 (4) [Avatar] Offline
Yes, from a C/C++ perspective, absolutely, it would be translated to const. However given the code samples were in Java, thus final doesn't give the same guarantees as in C/C++.

On my end the book is still marked as MEAP so I thought I'd give feedback. But it's good to know that printing has started, looking forward getting the hard copy.