Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    When it comes to arrays, people suggest cloning it first in the setter. stackoverflow.com/questions/6665150/… Then the question is - when to clone objects? Commented Mar 31, 2016 at 19:11
  • In general I wouldn't have a setter and getter for the internal data structures of my classes, as that is exactly what you want to have hidden/encapsulated. I have added another example in the original post Commented Mar 31, 2016 at 19:20
  • See programmers.stackexchange.com/a/21809/51711 for more info Commented Mar 31, 2016 at 19:27
  • Yes, but my array is not an internal data structure - it's a result of some calculations and I've chosen to storem them in an array for performance reasons. The class exists for exactly this purpose - to be able to store the result array and some additional information. Commented Mar 31, 2016 at 19:30