|
|
One significant point pertains to the use of global variables in the SVG examples in this book. As a general programming practice, it's preferable to use local variables so that you can avoid the side effects that can occur when modifying global variables (and at the same time make your code reusable).
The rationale behind using global variables, all of which are listed near the beginning of each SVG document, is that this approach enables you to focus as much as possible on the details of generating a particular graphics image. The problems that can occur with global variables will not occur in the examples in this book because the code is essentially 'stand-alone'; that is, it's not part of a 'library' that can be invoked with ECMAScript functions in other SVG documents. Once you have firmly grasped the logic and the purpose of the code in each example, it will be much easier to refactor the code by replacing global variables with local variables.
|
|