#74 prototype: GenericObject

Aberto
há 4 anos atrás aberto por ranides · 4 comentários

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 comentado há 3 anos atrás
Proprietário

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 comentado há 3 anos atrás
Proprietário

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 comentado há 3 anos atrás
Proprietário

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 comentado há 3 anos atrás
Proprietário

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) ```
Faça login para participar desta conversação.
Sem Objetivo
Sem utilizador atribuido
1 Participantes
A carregar...
Cancelar
Guardar
Ainda não existe conteúdo.