#59 SharedList

닫힘
ranides4 년 전을 오픈 · 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 년 전
소유자

CopyList done

CopyList done
로그인하여 이 대화에 참여
마일스톤 없음
담당자 없음
참여자 1명
로딩중...
취소
저장
아직 콘텐츠가 없습니다.