#74 prototype: GenericObject

Avoinna
4 vuotta sitten avasi ranides · 4 kommenttia
ranides kommentoitu 4 vuotta sitten

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 kommentoitu 3 vuotta sitten
Omistaja

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 kommentoitu 3 vuotta sitten
Omistaja

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 kommentoitu 3 vuotta sitten
Omistaja

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 kommentoitu 3 vuotta sitten
Omistaja

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) ```
Kirjaudu sisään osallistuaksesi tähän keskusteluun.
Ei merkkipaalua
Ei osoitettua
1 osallistujaa
Ladataan...
Peruuta
Tallenna
Sisältöä ei vielä ole.