Increasing Programmer Productivity

Tasking techniques can improve programmer productivity by modifying the behavior of existing programs, by allowing you to use programs as modules in a larger application, and by allowing multiple programming languages to be used in an application.

Modifying Program Behavior

Sometimes a program is designed to run in a particular environment, and later that environment changes. For example, a program might be designed to read a file on a family named DATAPK. Later, you might want to run a copy of that program on a different system that does not have a family with that name. Rewriting the source program and recompiling it can be a time-consuming process. Fortunately, many such behaviors can be modified through task attribute assignments.

For example, there is a task attribute called FAMILY that causes a process to use files on a different family than it otherwise would. Suppose a process expects to find all its input files on the family named DATAPK. You can assign the FAMILY task attribute a value of “DATAPK = CONTROL OTHERWISE DISK.” This causes the process to look for all its input files on the family named CONTROL instead of the family named DATAPK.

You can assign a task attribute to a process in any of the following ways, none of which requires recompiling or rewriting the program that is being initiated:

  • If you are running a program from CANDE or MARC, you can append task attribute assignments to the RUN command that initiates the program.

  • You can use a WFL MODIFY statement to assign default task attribute values to an object code file. The system assigns these task attribute values each time the object code file is run.

  • ALGOL, COBOL, and WFL all allow you to assign task attributes to a task variable. If you then specify this task variable in a statement that initiates a separate program, the task attribute assignments are applied to the new process.

The Task Attributes Programming Reference Manual gives examples of these methods of assigning task attributes.

Using Programs as Modules

A module is a body of code that can be reused in a variety of different contexts. The use of modules simplifies the programmer's job by making it unnecessary to repeat large amounts of code. One advantage of tasking is that it allows you to use an entire program as a module in one or more larger applications.

For example, you could have a report-formatting and printing program. You might also have a program that retrieves customer data from a database, and another program that does an inventory analysis. The customer data program and the inventory analysis program could both use process initiation statements to invoke the report-formatting and printing program and cause it to create reports using the data collected.

Tasking is only one of the methods that the system provides for allowing code to be reused by different programs. Some of the other methods are

  • Compile-time options

    You can use a $INCLUDE option in a program source file. At compilation, the compiler inserts text from a separate source file specified by the $INCLUDE option. This option is discussed in the manuals for each programming language.

  • Binding

    This technique enables you to insert a compiled procedure from one object code file into a separate object code file. This technique is documented in the Binder Programming Reference Manual.

  • Libraries

    This technique enables a process to dynamically invoke a procedure in another running process. This technique is described in Using Libraries.

All of these methods have their virtues. Compared to the $INCLUDE option or binding, tasking has the advantage of enabling you to maintain the shared module separately from the programs that call on it. You can make changes to the module without having to recompile another program or rerun the Binder.

On the other hand, both the $INCLUDE option and binding have the advantage of enabling you to insert an external procedure directly into the source or object program. Because the inserted procedure is treated by the system as an internal procedure, the main program can enter the procedure rather than initiating it. This results in savings of processor time and memory.

Compared to libraries, tasking has a slight performance advantage in some situations. Initiating a program carries a certain cost in terms of processor time, memory, and so on. The cost of entering a library procedure varies, and it can be higher or lower than the cost of initiating a process. For the first call on a particular library, the system must initiate the library process and establish a linkage between the calling program and the library. Once the library is running, it is more economical to enter a library procedure than to initiate a process.

Another advantage of the tasking method arises in situations where there already exists a program that performs a function needed by your application. You can initiate that program as a process without having to rewrite or recompile the program that performs the function. Changing the program into a library would require rewriting, and binding the program into another program requires using the Binder utility.

Using Multiple Languages in an Application

Different programming languages have different unique capabilities. These might make it easier to implement some types of routines in one language, and other types of routines in another language. If the same application requires routines in two or more different languages, then those routines have to be stored in separate source files and compiled separately.

One way to enable an application to use modules written in different languages is through tasking. You can accomplish this by using statements that initiate separate object code files. For example, you can write a COBOL program that initiates another program written in ALGOL.

A nice thing about this technique is that the system also enables you to pass parameters between programs written in different languages. The operating system allows parameters to match as long as they are of compatible types. Using Parameters explains which parameter types are considered compatible by the operating system.

Alternatively, you could use binding or libraries to create an application that uses modules written in different languages. The advantages of using tasking instead of binding or libraries are introduced under “Using Programs as Modules” earlier in this section.