#74 prototype: GenericObject

Öppen
öppnade 4 år sedan av ranides · 4 kommentarer
ranides kommenterad 4 år sedan

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")
ranides kommenterad 3 år sedan
Ägare

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}.
ranides kommenterad 3 år sedan
Ägare

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?
ranides kommenterad 3 år sedan
Ägare

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.
ranides kommenterad 3 år sedan
Ägare

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) ```
Logga in för att delta i denna konversation.
Ingen Milsten
Ingen förvärvare
1 Deltagare
Laddar...
Avbryt
Spara
Det finns inget innehåll än.