July 20, 2000 - Benefits of Dynamic Properties | WebReference

July 20, 2000 - Benefits of Dynamic Properties

Yehuda Shiran July 20, 2000
Benefits of Dynamic Properties
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Dynamic properties simplify and minimize the amount of code you have to use in a page. Without dynamic properties, element properties must be declared with constants only. The problem with constant properties is that they are not suitable for animation, which appears to be the complete opposite of constancy. In order to implement an animation in an HTML page, you have to explicitly recompute element properties over and over again, at pre-defined time intervals. You can find such animation in our columns. For example, see Column 18, JavaScript Animations, Part I and Column 19, JavaScript Animations, Part II. Using dynamic properties, you will write less code. You still need to specify the functional dependency of element properties in the beginning of your code; then you let JavaScript do the job for you. You don't have to touch these elements ever again. Dynamic properties do not avoid JavaScript scripting at all, but with a little coding, you'll make a lot of coding obsolete.

Dynamic properties are similar to a spreadsheet's implementation of a formula. A cell's value can be a constant or a formula. A formula can include references to any number of other cells in the spreadsheet. Likewise, a dynamic property can reference properties of other elements on the same document, as well as regular variables and functions.

One of the benefits of dynamic properties is that once you find the functional dependency, you don't have to monitor or maintain the page. You describe in formulas the mathematical dependency between objects, properties, and variables. This dependency is always valid and is kept by the browser itself, with no scripting interruptions.

Using dynamic properties is more efficient. With constant properties, upon a certain event, you had to go over all elements on the page and update them. With dynamic properties, you figure out the exact dependencies up front, so you never update a property without a definitive need. Continuing the spreadsheet analogy, it is much more efficient to update those cells that need to be updated according to the formulas assigned to them than to check which cells need to be updated and then update them.

For more on Dynamic Properties, go to Column 65, Dynamic Properties.