Re: [Jalview-dev] Defensive copying and alternatives

2016-09-16 Thread Jim Procter
Hi Mungo On 16/09/2016 14:07, Mungo Carstairs (Staff) wrote: > I fell to wondering why Java doesn't provide things like a 'read-only' > view of a collection...thinks...you could wrap a List with a List > that overrides all update methods to throw an exception...Googled for > this...well well it

[Jalview-dev] Defensive copying and alternatives

2016-09-16 Thread Mungo Carstairs (Staff)
Lifted from discussion in http://issues.jalview.org/browse/JAL-2001. There are pro's and con's to returning a copy of internal state rather the actual object (e.g. ColumnSelection.getSelected()). Pro: prevents inadvertent modification that might break the internal consistency of the object