May 4, 1999

Make Your JavaScript Code More Readable Using the with() Statement

The with() statement in JavaScript is identical to the With statement found in Visual Basic. Using with(), you can reduce object references and make your code more readable. Surprisingly, it is possible to have nested with() statements. For example, this code: function foo(){ var x = document.forms[0].elements[0].value; var y =

Add Tiny Scripts to Your Favorites With Bookmarklets

Did you know that you could write pure JavaScript in the address bar of Internet Explorer or Netscape? You can also write pure JavaScript in the Start/Run dialog in Windows. Try typing this code into either the address bar or the Start/Run dialog: Javascript:alert(“hello world!”); With a limit of 255

Avoid Gigantic Classes

Several small and specialized classes are preferred to a single bulky class that contains hundreds of member data members and member functions. More than once I’ve seen programmers extending a class with additional member functions and data members instead of using more plausible object-oriented techniques such as derivation. As a

Specifying Position When Adding Components

The java.awt.Container class provides a number of different overloaded versions of the add() method which are used to add components to the container. The integer value specified with the add(Component, int) method represents the component’s position within the container’s list of subcomponents. This position should not be confused with the

Keep Indexes Separate From Data

You can boost your performance greatly by separating indexes and data onto different physical disks, which allows both the index and data to be accessed at the same time. However, in SQL Server 6.5, the only way to do this was to use the concept of segments, which complicated maintenance.

Counting the Occurrences of a Substring

VB6 has introduced the Replace function, which replaces all occurrences of a substring with another substring. Although this function is useful in itself, you can also use it in unorthodox ways. For instance, you can use it to count how many times a substring appears inside another string: Function InstrCount(Source