I use the readonly collection to prevent users from modifying my cached data, but the elements themselves are, of course, mutable. Is there a way to prevent this behavior?
Michelle
Either make the cached items immutable, or skip copies of objects.
you can set the private constructor, so only internal elements can instantiate.
Alternatively, you can use the constructor to place read-only values ....
One way is to have both an immutable and a modified version of each object of the business model. I wrote an article about it here: http://rickyhelgesson.wordpress.com/2012/07/17/mutable-or-immutable-in-a-parallel-world/
Source: https://habr.com/ru/post/1384692/More articles:Attempting to send the created text file as an email attachment - from the default folder - androidDisplay message about successful warning when sending mail with MFMailComposeViewController on iPhone - emailC ++: sudoku (copy) - c ++CodingBat sum67: why is this solution wrong? - pythonDownloading the file with the answer does not show the file size - htmlIs there any way to ignore uppercase when trying to find linkText link with Webdriver? - javaGet size Response.output? - asp.netmaps 5.0 enterprise library caching between datareader and user classes for accessor methods - performanceJCS disk cache issue - javaWhere can I find XSD or DTD for the XSLT 1.0 specification? - xslt-1.0All Articles