PolymerElements / app-storage

Data-pipes and specialized services
61 stars 47 forks source link

Implement This As A Strategy Pattern #57

Open phidias51 opened 8 years ago

phidias51 commented 8 years ago

Since the development process often starts by using static JSON files before migrating to other forms of storage, it would be useful if this were implemented as a strategy pattern, with the ability for the developer to switch back and forth between implementations. Something like:

<app-storage config-name="cache+firebase" config="myapp-config.js"></app-storage>

The config file would let you have different named configurations.

[{
  "name":"cache+firebase",
  ... caching config
  ... firebase config
},
{
  "name":"cache+file",
  ... caching config
  ... file config
}
]
cdata commented 8 years ago

Hi, thanks for the suggestion. Could you provide a more detailed description of the strategy pattern, or perhaps link to some relevant literature that you think speaks to how it could be applied here?

phidias51 commented 8 years ago

@cdata Here's some information on Strategy Patterns. https://en.wikipedia.org/wiki/Strategy_pattern

In a nutshell, I want to be able to easily switch between different storage strategies. For example, suppose I have a configuration called "dev" that lets me use local JSON files for early development work. Once I'm satisfied with that, I might switch to "stage" mode, where I use a firebase database. What the modes are called should be completely configurable, and there should be some way of a doing a global switch from one mode to the other. Perhaps there might be some global application parameters for this.