Step One: Watch Writing Testable JavaScript - Rebecca Murphey from Full Frontal 2012 (award for worst conference name ever?)
Step Two: Fork this gist.
Step Three: Respond to this question in your fork: Consider the four responsibilities that Rebecca lists for client side code (hint: they're color coded). Respond below with your thoughts. Did any of the responsibilities that she lists surprise you? Do you feel like you mentally split your client side code in IdeaBox and other past projects into these responsibilities?
I had a few good takeaways from this, but it really wasn't that easy for me to separate what she was talking about into the four responsibilities. I don't feel like my IdeaBox in any way split this up, and I'd love to try refactoring it as a practice exercise. I think in Rails apps I had gotten to the point of splitting things up nicely in the models, views, and controllers, and this talk made some points that I could connect to that. Nothing she said surprised me, and I really liked the way she talked about testing and using it to drive her process of organizing the code into the four different areas to detangle it from how it was at the beginning. I also liked the guiding principles: Use constructors to create instances. Support configurability. Keep methods simple. Don’t intermingle the responsibilities below… OH. And test first!
Step Four: Totally Optional: take a look at some of the other forks and comment if the spirit moves you.
I feel yah.... It's SO frustrating going from feeling comfortable in Rails with testing and learning to really depend on it, and then being like 'I have... no idea... how to do this in JavaScript.' I think that's why a lot of ruby developers have strong negative feels towards JavaScript.