#59 SharedList

Затворено
отворено пре 4 година од ranides · 3 коментара
ranides коментирира пре 4 година

We should have a list wrapper which offers access to internal/source list and allows exposing its' content to public consumers in a safe way.

"Safe" means, that every time returned public list must behave like defensive, shallow copy.

Because of performance reasons, we wont create shallow copies over and over again, but return protected views.

We should have a list wrapper which offers access to internal/source list and allows exposing its' content to public consumers in a safe way. "Safe" means, that every time returned public list must __behave__ like defensive, shallow copy. Because of performance reasons, we wont create shallow copies over and over again, but return protected views.
ranides коментирира пре 4 година
Власник

class SharedList will have fields:

  1. source: List
  2. view: PublicList
  3. data: PrivateList

The source one must be hidden from everyone.

PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter.

Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners".

Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.

class SharedList will have fields: 1. source: `List` 2. view: `PublicList` 3. data: `PrivateList` The source one must be hidden from everyone. PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter. Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners". Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.
ranides коментирира пре 4 година
Власник

Maybe whole functionality is pointless and we should accept the fact, that we can't control changes inside source? We should just implement something different, called: "FastCopy" which will detach on their own, but it won't detach eralier.

I mean: FastCopy will tell to everyone: "I am just a view, until you try to modify me"

Maybe whole functionality is pointless and we should accept the fact, that we can't control changes inside `source`? We should just implement something different, called: "FastCopy" which will detach on their own, but it won't detach eralier. I mean: FastCopy will tell to everyone: _"I am just a view, until you try to modify me"_
ranides затворено пре 4 година
ranides коментирира пре 4 година
Власник

CopyList done

CopyList done
Пријавите се да се прикључе у овом разговору.
Нема фазе
Нема одговорних
1 учесника
Учитавање...
Откажи
Сачувај
Још нема садржаја.