Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Data Based JavaScript

Tim Griesser
December 15, 2014

Data Based JavaScript

Tim Griesser

December 15, 2014
Tweet

More Decks by Tim Griesser

Other Decks in Technology

Transcript

  1. Some Thoughts, Opinions Backbone Models & Collections do too much

    Backbone Models & Collections alone aren’t enough
  2. Some Thoughts, Opinions Backbone Models & Collections do too much

    Backbone Models & Collections alone aren’t enough There’s better ways than listening to individual change events
  3. Some Thoughts, Opinions Backbone Models & Collections do too much

    Backbone Models & Collections alone aren’t enough There’s better ways than listening to individual change events
  4. Backbone Models & Collections (might) do too much Wrapping Data

    (attributes, get, set) Validations Change Notification Relations??? Syncing?? App Specific Logic Models
  5. Backbone Models & Collections (might) do too much Wrapping Data

    (attributes, get, set) Validations Change Notification Relations??? Syncing?? App Specific Logic Wrapping models Adding, removing, fetching models Tight ties with model (change / url) Maybe pagination??? Maybe nested models?? Maybe…whatever else you want to put there? Models Collections
  6. What should they do Wrapping Data (attributes, get, set) Return

    external relations based on attributes Limited Change Notification App Specific Logic Filter models Models Collections
  7. Backbone.Model and Backbone.Collection might not be enough Multiple “sources of

    truth” Object Identity issues No definitive place of knowing what data exists in your application
  8. What does this gain us? Drastically simplifies Collections Single source

    of truth for everything data related Easy to switch into offline mode
  9. var x = new Immutable.Map({a: 1}); ! var y =

    x.set('b', 2); ! x.get('a') // 1 ! y.get('a') // 1 ! x.get('b') // undefined ! y.get('b') // 2
  10. Takeaway Points If you like Node but want RDBMS check

    out Knex & Bookshelf Maybe Backbone.Session could be a thing?
  11. Takeaway Points If you like Node but want RDBMS check

    out Knex & Bookshelf Maybe Backbone.Session could be a thing? Or maybe &.Session?
  12. Summary Time spent critically analyzing the data flow in your

    application can save a lot of time later