O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implement Code Modularity: Don’t Cajole an Entire Project

Note

Testing code often by passing it through the cajoling process can help eliminate issues early and give developers a good idea of their project’s progress.

One of the worst things that a developer can do when cajoling a block of code is to attempt to cajole a large amount of JavaScript at once. (If you are new to Caja, doing this might traumatize you.) Most likely what will be produced is an extensive number of warnings and errors about issues with the code, many of which may be reported due to other errors or warnings in the code. This will tend to scare away many developers and may not be a very accurate representation of the code’s issues.

Developing code in a modular fashion—e.g., building encapsulated reusable blocks in standard functions—is the first step in ensuring that it can be tested in blocks. The goal to this approach is the ability to integrate function by function into the script that is being cajoled, so you can deal with errors and warnings from the cajoling process in a much more manageable way.

When migrating an existing code base to an environment that runs Caja, you can use this approach as well. Working with small blocks of code instead of attempting to debug an entire code base can help you manage the output of the cajoling process.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required