Writing

Journal Articles

I have written articles for software training journals and newsletters, both print and online. Below is an excerpt of an article I wrote for ZD Journals and ZDNet.


Screen capture of a portion of a ZDNet article by Brian WilsonObjects provide a way for you to structure your data and functions so they are natural to work with. For example, to add an employee named Fred Smith to a database, you might write a statement such as:

employee.add("Fred Smith");

This is somewhat more terse and self-explanatory than:

employee[employee.length + 1] = "Fred Smith";

Another (perhaps more important) benefit of objects is that they're self-contained or encapsulated. This makes for code that is both easy to re-use and to share. An object defines a data structure (data members, fields, or properties) and functions (methods) that manipulate that data structure. When programmers use an object, they do not need to know how its methods were programmed. They simply need to know what the methods are named and what arguments they expect to receive. For example, you've probably already used the Window object's alert() method to display a simple message box. To use this method, you simply need to know that the alert() method exists, and that it accepts one argument (the message that it will display). You don't need to know how JavaScript's developers wrote the alert() method to be able to use it.

Training materials

I have developed more than 40 courses for Logical Operations, Ziff-Davis Publishing, and Element K. Some of these consisted of student and instructor training manuals (and supporting media, like PowerPoint slides, data files, and Director interactives), while others were Web-based self-study tutorials, or instructor-led distance learning. Here are some examples of text taken from courses I have written:

Attenuation

The electronic signals that are used to transmit data through a network are prone to attenuation--a loss of signal strength or quality. The greater the distance that signals must travel, the greater the attenuation that they experience. You might think of water streaming out of a garden hose as an analogy. Water sprays out of the end of the hose with a certain amount of force, which enables the water to stream through the air. As the water travels away from the hose, gravity and friction attenuate the force of the stream, and eventually there is not enough concentrated force to keep the water in the air. By amplifying or regenerating a signal, you can extend the distance that a signal can travel.


Introduction to the Cookie Object

When JavaScript code creates variables and objects, they exist in memory only as long as the Web page that created them is still loaded. As soon as you move to another page, the browser performs garbage collection and removes them from memory. If you want to carry a value across pages, you need to have a way to set the value aside for later retrieval. A common way to do this is to store the value in a cookie.

A cookie is a small chunk of string data stored on a Web client's local disk. The Windows version of Navigator stores cookies in a single file in a subdirectory of the directory that holds the Navigator program. The Macintosh version of Navigator stores cookies in a folder beneath the Preferences folder, in a single file called MagicCookie. The Macintosh and Windows versions of Internet Explorer store each cookie as a separate file in a Cookies folder that is stored within the system folder.


Methods

In JavaScript, methods are functions that are stored as a property of an object. For example, the employee object that you considered earlier might have methods such as changeSalary( ), transfer( ), or fire( ). It makes sense to include these functions as members of an employee object because they are things that you might do to an employee. It would not make sense to apply these functions to objects such as cubicles, debits, or fleetVehicles. For example, you might fire an employee, but it is unlikely that you would try to fire a cubicle. By encapsulating a particular method within an object, you provide a logical way to associate functions with the data on which they operate.

You declare a method much the same as you would declare any other function. To associate the function with the object, you simply store the function within one of the object's properties. Let's see how this is done in the sample script below.

1.  function Employee_changeSalary() {
2.    var newSalary = prompt("What is the new salary?", this.salary);
3.    // (Validation routine would go here...)
4.    this.salary = newSalary;
5.  }
6.
7.  function Employee (theName, theHireDate, thesalary) {
8.    this.name         = theName;
9.    this.hireDate     = theHireDate;
10.   this.salary       = theSalary;
11.   this.changeSalary = Employee_changeSalary;  // Declare method
12. }
      

The Employee_changeSalary function will be a method of the Employee object. In line 11 of the Employee constructor function, the Employee_changeSalary function is assigned to the changeSalary property. In methods, as with constructor functions, the this keyword refers to the object itself. Notice that neither the method name (this.changeSalary) nor the function reference (Employee_changeSalary) is followed by parentheses. When JavaScript encounters a function name followed by parentheses, it attempts to run that function. When assigning a property to a method name, you do not want to call the function; you want to refer to the function itself.

Given the declarations above, you could create a new employee by using the following statement.

employeeX = new Employee ("Fred", 1997, 45000);

Then you could change the employee's salary as follows.

employeex.changesalary ();

The rules for naming methods are the same as those for any function. However, you might find it beneficial to use a naming scheme like the one used for Employee_changeSalary. This approach helps to identify this function as a method, rather than just another run-of-the-mill function. In this scheme, the first part of the function name (before the underscore character) identifies the object to which the method belongs, and the second part identifies the purpose of the function. It is a good habit to make the second half of the function name identical to the name you assign to the property that holds the method.

Typically, you assign a function to an object property within a constructor function. However, you could make the assignment outside of the constructor, and you could even assign a new method to predefined objects, such as Window.

Distance learning

I have developed distance learning courseware that are used by a variety of customers, including Ziff-Davis University, Element K, SmartPlanet, Barnes & Noble University, the U.S. Navy Manufacturing Technology (MANTECH) Program, U.S. Army Medical Department (AMEDD). Click the link below to view writing samples from a Web-based distance learning course that I developed.

Web-based distance learning sample

NOTE: Content samples displayed on these pages are taken from copyrighted works. These materials are being provided in this electronic portfolio with the permission of their respective owners, and are not to be copied or used for any other purpose. A more comprehensive sample of my work is available on CD-ROM.