From COBOL to OOP

3.3: Procedures

3.3 Procedures

Procedures avoid duplicate code

To ensure a better program structure, you could group several instruction blocks to form a single procedure. For this purpose, we write a procedure that includes all instructions. When the functionality of the instruction block is required later on, it will be sufficient to just call this procedure. This is particularly useful when the instruction block is used more than once. Instead of permanent duplicate code, all that needs to be done is call the same procedure repeatedly.

Such procedures are also useful to ensure a good structure of your program, and they offer you an option to implement user-defined operations. Procedures are basically nothing new, because COBOL also offers the option to call "internal subprograms" by using the PERFORM function.

Java particularity

These procedures form the basis for the methods we will introduce later, which play a major role in object-oriented programming.

Java has no "real" procedures only methods. Because this may be confusing in the beginning, we do not discuss this issue here in detail. The somehow complicated definition of a procedure as a method of a class will become clear at the latest in Section 5.1.

First overview

This subsection provides an initial overview of procedures. First, we introduce parameterless procedures, which serve to avoid duplicates. Then we discuss parameters and local names of procedures. Finally, we discuss functional procedures, which are procedures that return a result, and recursion. Subsequent sections provide additional information about procedures.

3.3.1 Parameterless Procedures

Parameterless procedures...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Programmable Logic Controllers (PLC)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.