The question is asked regarding an environment with garbage collection.(Java, AS3)
I am writing a level editor using MVC and the view needs to have read only access to the data in the model for rendering purposes. This can be done in AS3 in several ways:
- With a function that retrieves the contents of each specific object by index.
- Updating with all the recently modified objects(complicated), this requires keeping the id of the view and the last update date. Keeping the objects sorted by the last change date and then pushing in all the newly changed objects.
- Returning a copy of the whole array every time.
What is the most effective way to handle a read only array(not implemented in the language)? Does anyone have performance statistics that shows the performance boost gained for using method 2? And when is method 1 severely inferior to method 3.