Organizing Your Code with Testable jQuery Plugins 2.57


At Carbon Five we've used jQuery on a wide range of consulting projects over the past three years—from simple progressive enhancement of the user interaction to rich Javascript applications, chat clients and charting. We have experimented with different ways to structure our code: none, MVC, etc. We finally evolved to a style that allows us to build complex pages, with numerous plugins, without creating a mess of Javascript.

These learnings have been driven by our desire to unit test our code, and at times, do test-driven Javascript development. Through those experiences we've learned good patterns for structuring and testing our code.

Showing real-world examples, we'll talk about:

  • Using the jQuery plugin model to structure our code. We have adopted this pattern not just for re-usable plugins, but also for page-specific code. We've evolved our thinking as to what the page should do, what the plugin should do, and what markup should be on the page. What are good patterns to divide responsibilities?
  • Using BDD to test drive JavaScript coding. When you have a general notion of where you are going, the best technique may be to write tests to home in on the requirements. We have been fairly successful using this technique, including in areas where you might not expect—like drag-n-drop
  • Getting the full benefit out of unit tests by making them executable in an automated fashion on a continuous basis. We've been successful using BlueRidge (and a similar Maven offering) to run our Javascript unit on continuous integration servers (Bamboo/Team City). These have proven much more reliable than our forays into doing the same thing with Selenium and in-browser driving of JSUnit. We'll discuss this technique and walk through setting it up.

Comments on this Talk

Avatar-missing-icon-08 typesett, 26 Apr 03:58 AM

Thank you for sharing and I appreciate you for coming out and doing this. I realize that you don't "speak" for a living but your monotone delivery was difficult to overcome at times. If you do this again, I think you should take note of your favorite speakers and try to emulate them to better share your ideas as well as your personality with the crowd. As for your content, I wish you showed other ways of testing such as qUnit more...

Avatar-missing-icon-07 , 01 Sep 02:40 PM

Reliable and professional China wholesale website where you can buy wholesale merchandise and dropship them anywhere in the world

China wholesale: The leading marketplace for wholesale products from Chinese Wholesaler and suppliers, including wholesale,Wholesale lipo battery,mobile signal booster,Wholesale Laser Pointer....

Avatar-missing-icon-04 , 06 Sep 10:44 PM

28 Aug 2010 ... Fruta Planta is formulated to help users to reduce their appetite and ... What makes Reduced Weight Botanical Slimming Soft Gel the most effect weight loss Japan 2 Day Diet Lingzhi Instant Slim Tengda Diet Pills...

Have an account? Sign in or register.

Leave a Comment

3 Ratings: 2.57

Delivery: 2.23

Content: 2.90