#74 prototype: GenericObject

オープン
4 年 前ranides によって開かれました · 4 コメント
ranides4 年 前 にコメントしました

Something similar to GenericMap or especially PrototypeMap but supports situation where multiple keys points to the same property (by identity). For example, row cell from excel row can access in 3 ways:

  • by cell index: get(4)
  • by cell name: get("D")
  • by cell header name: get("First name")
Something similar to `GenericMap` or especially `PrototypeMap` but supports situation where multiple keys points to the same property (by identity). For example, row cell from excel row can access in 3 ways: - by cell index: get(4) - by cell name: get("D") - by cell header name: get("First name")
ranides3 年 前 にコメントしました
オーナー

GenericMap and GenericKey isn't useful in our situation. Maybe we can use PrototypeMap with some "tricky" key wrapper? That means: we can have Map which simply maps "public keys" into some uid and PrototypeMap which stores mappings {uid => value}.

GenericMap and GenericKey isn't useful in our situation. Maybe we can use PrototypeMap with some "tricky" key wrapper? That means: we can have Map which simply maps "public keys" into some uid and PrototypeMap which stores mappings {uid => value}.
ranides3 年 前 にコメントしました
オーナー

The fact that PrototypeMap is a class is a problem more and more. Maybe we should split it into PrototypeMap interface and OpenPrototypeMap? Or add extension points? For example for optional key mapping before get/put operation?

The fact that PrototypeMap is a class is a problem more and more. Maybe we should split it into PrototypeMap interface and OpenPrototypeMap? Or add extension points? For example for optional key mapping before get/put operation?
ranides3 年 前 にコメントしました
オーナー

To be honest, we already did that inside ObservablePrototypeMap. We should follow the pattern and just use internally our own map implementation for "declared" field.

To be honest, we already did that inside ObservablePrototypeMap. We should follow the pattern and just use internally our own map implementation for "declared" field.
ranides3 年 前 にコメントしました
オーナー

So finally, maybe we should do the opposite: make PrototypeMap final class and create builder/factory methods for observable, multi-index instances:

PrototypeMap
    .fromPrototype(parent)
    .listener(...)
    .listener(...)
    .indexer(by int...)
    .indexer(by cell name...)
    .indexer(by header name...)
    .build()

Of course, if prototype is observable, we should connect it to our map too. Just equivalent to:

    .fromPrototype(parent)
    .listener(parent.router())

Question, maybe our PrototypeMap should directly implement Router? Then we could use shorter version instead (so without any router magic):

   .fromPrototype(parent)
   .listener(parent)
So finally, maybe we should do the opposite: make PrototypeMap **final** class and create builder/factory methods for observable, multi-index instances: ``` PrototypeMap .fromPrototype(parent) .listener(...) .listener(...) .indexer(by int...) .indexer(by cell name...) .indexer(by header name...) .build() ``` Of course, if prototype is observable, we should connect it to our map too. Just equivalent to: ``` .fromPrototype(parent) .listener(parent.router()) ``` Question, maybe our PrototypeMap should directly implement `Router`? Then we could use shorter version instead (so without any router magic): ``` .fromPrototype(parent) .listener(parent) ```
会話に参加するには サインイン してください。
マイルストーンなし
担当者なし
1 参加者
読み込み中…
キャンセル
保存
まだコンテンツがありません