#59 SharedList

Geschlossen
vor 4 Jahren geöffnet von ranides · 3 Kommentare
ranides kommentierte vor 4 Jahren

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 kommentierte vor 4 Jahren
Besitzer

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 kommentierte vor 4 Jahren
Besitzer

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 hat vor 4 Jahren geschlossen
ranides kommentierte vor 4 Jahren
Besitzer

CopyList done

CopyList done
Anmelden, um an der Diskussion teilzunehmen.
Kein Meilenstein
Niemand zuständig
1 Beteiligte
Laden…
Abbrechen
Speichern
Hier gibt es bis jetzt noch keinen Inhalt.