<<>>UpTitleContents

6.3.3.1.


3GLs and object oriented class libraries

Any Third Generation Language (3GL) that has a suitable GUI compiler may be used to write CBL material, and there are several advantages to this approach to development. Conventional programming languages are currently much more flexible than the available 4GL's or CBT oriented authoring systems, and compiled code is inevitably much faster and more compact than anything that has to carry the baggage of a runtime version. However the lead-time of development using relatively low level programming is likely to be very much greater than that using most authoring systems, and the level of skill required by the developers is much greater.

If a 3GL is to be used for development then the choice of language is critical. It would be beyond the scope of this report to discuss the relative merits of programming languages, but it is worth briefly considering the philosophy behind three of the most commonly used languages - BASIC, Pascal and C. The further removed any language is from the machine code of the computer the "higher level" it is said to be. Low level languages are more flexible than high level languages, but they are also more difficult to use and more prone to bugs. Assembly language is the lowest level language of all (short of raw binary), C is a low level 3GL, Pascal is higher level and BASIC is higher level still. This is illustrated by the simple "Hello World" programs shown in Table 6.5)

The philosophy of C programming is to restrain programmers as little as possible and thus allow them to write anything that they like, but this does require that a lot of information about the technical aspects of the program must be provided. For example in our "Hello World" program a buffer must be set up in memory to contain the 12 characters of the message and a thirteenth terminator, then the display command needs to specify the type and format of data that is to be displayed. Thus C is an extremely flexible language but it does make the assumption that programmers know what they are doing!

Pascal is superficially very similar to C but it is much more rigidly structured. The philosophy of Pascal is to attempt to make errors syntactically illegal so that it is easier to write bug free code, although the cost of this is that it is a much less flexible and the language itself is more likely to impose limitations on the program design. BASIC is a highly simplified language in comparison with C or Pascal that makes it much easier to write simple programs. It lacks the rigid imposition of a structure that Pascal provides and so long BASIC programs can become more complex than their Pascal counterparts.

These three 3GL's are all commonly used in CBL development. BASIC is incorporated into the macro language of various productivity tools and authoring systems, and recently has been given a radical new lease of life in the form of Microsoft's Visual Basic (see below). Pascal and C have both been extended to incorporate object oriented programming (OOP) design technology, and these extended versions are known respectively as Object Pascal and C++.

The major problem with developing CBL in a 3GL is that the modern GUI's that most CBL employ are highly complex environments. This may be illustrated by comparing the "Hello World" programs of Table 6.5) (these display the message "Hello World!" in a text based environment such as text mode DOS or UNIX) with the GUI equivalent of these shown in Table 6.6) (1). This is a Windows program that pops up a window containing the message "Hello World!"; As may be seen even a task as trivial as this can require a non-trivial amount of programming to effect in a GUI. A partial solution to this problem is to use an OOP class library to provide a set of standard Windows objects.

The phrase "object oriented" means the representation of real or conceptual "objects" as data entities within the computer, and it is a highly fashionable and much abused term. Virtually every authoring system, graphics package and operating environment claims in some way to be object oriented. For example Corel Draw is said to be object oriented because a drawing consists of a number of individually manipulable objects, Windows and the Mac operating system are said to be object oriented because they use semiotic icons to represent actions, and Authorware is said to be object oriented because it uses icons to represent activities. However the term Object Oriented Programming (OOP) has a much more precise meaning, although it is derived from the same concept.

There are three major tenets of the OOP principle - Encapsulation, Inheritance, and Polymorphism. Encapsulation involves combining data and the program code that manipulates that data to form a data type called an object. Inheritance involves defining a parent object and then deriving a hierarchy of descendent objects from this - all of which are able to inherit their ancestor's code. Polymorphism involves a function with a single name having different effects when used by different objects. There are a number of languages available that were originally designed to be object oriented (eg Smalltalk), but most of these are interpreted and semi-experimental. However, object oriented extensions are used in C++ and Object Pascal, and these can radically simplify the process of writing applications for GUI's such as Windows owing to the existence of object oriented class libraries.

An object oriented class library for a GUI is a library of objects that allows the construction of an application without the detailed knowledge of the Application Programming Interface (API) that would otherwise be required. An example of such a library is the Borland Object Windows Library (OWL) that is bundled with Turbo Pascal and C++ for Windows. It is then relatively easy to define an object as a descendent type of a standard library object and modify it as required. A library object may be relatively self contained such as a dialog box, or it may be a control object such as a scroll bar, or it could even be a full blown text editor.

An example of OOP using OWL with Turbo Pascal is given in Table 6.6) . This is a Windows "Hello World" program, with version (1) using Windows API calls and version (2) using OWL to enable the code to be much shorter and easier to understand. Two objects are used here "THelloApp" is a descendent of the library object "TApplication" that defines a standard Windows application. The second object is "THelloWindow" that is a descendent of the "TWindow" library object that defines a standard Windows window. Class libraries of this type can be extremely useful to CBL developers who choose to use 3GL's because they allow the development of GUI applications without an extensive technical knowledge of the API, and thus they greatly increase productivity.


<<>>UpTitleContents