Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2:26:40 PM John Barnette: can I bounce an idea for a blog post/article off of you?
- 2:26:55 PM boss@topfunky.com: fire away
- 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.
- 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.
- 2:29:30 PM boss@topfunky.com: I've never thought of that
- 2:29:32 PM boss@topfunky.com: great idea
- 2:29:49 PM boss@topfunky.com: although, is session.user better than current_user ?
- 2:30:01 PM John Barnette: it's a shitload more testable, that's for sure :)
- 2:30:07 PM John Barnette: well, without a lot of dependencies
- 2:30:37 PM boss@topfunky.com: I've ended up duplicating current_user in some tests, but your mixin idea would be better
- 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
- 2:31:12 PM John Barnette: controller "helpers" like current_user smell very procedural to me
- 2:31:29 PM John Barnette: which is often fine, but i think the complexity line gets crossed really quickly
- 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?
- 2:31:53 PM boss@topfunky.com: And namespaces are thrown out with the bathwater
- 2:32:11 PM boss@topfunky.com: I've been tempted to use actual namespaced models instead of bare helper methods
- 2:32:21 PM boss@topfunky.com: Calendar.build(options)
- 2:32:26 PM John Barnette: yeah, once very early on I had Current.user and similar things :)
- 2:32:29 PM boss@topfunky.com: instead of calendar_tag(options)
- 2:32:35 PM John Barnette: absolutely
Add Comment
Please, Sign In to add comment