Guest User

Untitled

a guest
Mar 16th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. 2:26:40 PM John Barnette: can I bounce an idea for a blog post/article off of you?
  2. 2:26:55 PM boss@topfunky.com: fire away
  3. 2:28:29 PM John Barnette: "Sessions are People Too." Stop treating your webapp sessions like a stupid hash. Sessions have lifecycle, properties, and everything a model does: they even have a certain type of persistence. Start modeling your sessions. Include a module in CGI::Session (or equivalent) with actual methods on it. session.user, session.anonymous? session.cart.items, etc.
  4. 2:28:55 PM John Barnette: Is this too obvious for an article? It's showing a lot of benefits for us in code clarity, and especially in unit testing session behavior.
  5. 2:29:30 PM boss@topfunky.com: I've never thought of that
  6. 2:29:32 PM boss@topfunky.com: great idea
  7. 2:29:49 PM boss@topfunky.com: although, is session.user better than current_user ?
  8. 2:30:01 PM John Barnette: it's a shitload more testable, that's for sure :)
  9. 2:30:07 PM John Barnette: well, without a lot of dependencies
  10. 2:30:37 PM boss@topfunky.com: I've ended up duplicating current_user in some tests, but your mixin idea would be better
  11. 2:30:56 PM John Barnette: so the thing that's been very nice for us so far is that it lets you think of the session as a model with other dependent models. it makes me think about things in a much more OO fashion
  12. 2:31:12 PM John Barnette: controller "helpers" like current_user smell very procedural to me
  13. 2:31:29 PM John Barnette: which is often fine, but i think the complexity line gets crossed really quickly
  14. 2:31:51 PM John Barnette: current_user, current_whatever, current_skin, cart, etc -- at some point they're all "acting" like instance methods on the session, right?
  15. 2:31:53 PM boss@topfunky.com: And namespaces are thrown out with the bathwater
  16. 2:32:11 PM boss@topfunky.com: I've been tempted to use actual namespaced models instead of bare helper methods
  17. 2:32:21 PM boss@topfunky.com: Calendar.build(options)
  18. 2:32:26 PM John Barnette: yeah, once very early on I had Current.user and similar things :)
  19. 2:32:29 PM boss@topfunky.com: instead of calendar_tag(options)
  20. 2:32:35 PM John Barnette: absolutely
Add Comment
Please, Sign In to add comment