M/F 2:30-3:20   
in G01 Gates Hall

CS 1130: Transition to OO Programming

Spring 2016

Module 1.1. Structural versus Algorithmic Aspects

Overview

There are two major aspects of a programming language:

(1) the algorithmic or procedural aspect.

(2) the structural or organizational aspect.

You can make an analogy to a cookbook. Each recipe is a sequence of instructions to carry out in order to cook something. This is the algorithmic aspect.

The recipes may be organized in chapters —appetizers, entrees, desserts, breads, etc. Each chapter may be further subdivided into sections. This is the organizational aspect.

In a programming language, the algorithmic aspect has to do essentially with sequences of assignment statements, conditional statements, loops, and procedure/function calls.

When programming languages were first invented —starting in the 1950s with Fortran and moving on to Algol, Lisp, and Cobol about 1960— the major organizational tool was the subroutine (known today as the function, procedure, or method), which corresponds to a recipe in a cookbook. To add more function to a program, one added more subroutines, each of which did its own thing. This rather flat structure did not and does not scale up very well! Software systems consisting of hundreds or even thousands of subroutines were hard to manage and maintain. Yet, the subroutine continued to be the main structuring mechanism in popular programming languages well into the 1980s.

Various other organizational methods were developed. Many of these were organized around modules, which could contain collections of subroutines and other things. But the organizational method that has had the most success is object-orientation, or OO.


The basics of OO

Here's an analogy that will give the basic ideas of OO. A typical office has filing cabinets. Each drawer contains a bunch of manilla folders. The folders in one drawer have exactly same kind of information. They contain data (e.g. a person's name and address, the amount of money they owe). In addition, for OO, they contain instructions (called methods) for carrying out operations on the data —changing the data, checking the data, performing calculations. Because the instructions have been placed in each manilla folder, anyone in the office can do any job.

In OO, each file drawer is called a class, and each manilla folder in the file drawer is called an object of the class.

In addition:

1. One can write a class definition, which gives the format of the manilla folders of the class —what kinds of data and what instructions each manilla folder will contain.

2. The class definition for file drawer (class) SC can say, hey, let my manilla folders contain the same kinds of data and instructions as those defined for class C, in addition to defining more data and instructions. SC inherits everything from C. For example, a manilla folder for class Cornell undergrad will contain all the information and instructions of class Cornell student plus any information and instructions that pertain only to undergrads.

3. There is a simple way to create a new manilla folder (object) to go in a file drawer (class).

Now you know some essential features of OO. This course CS1130 shows you how these features are realized in the programming language Java.


History of OO

OO has its roots in the language Simula 67, which was developed in the late 1960's. But what was attempted at the time was not fully understood, and its ideas did not catch on. This happens often in science and engineering. Here are other examples. Charles Babbage conceived of computers and designed and tried to build some in the mid 1850s. He didn't have electricity! But the first working computers weren't constructed until the 1940s.

SmallTalk-71 was developed to try out "message-passing" ideas that were in Simula 67, and further explorations were done throughout the 1970s, all at the Xerox Palo Alto Research Center (PARC). In the early 1980's, SmallTalk-80 was shown to the world, and interest in OO grew, leading to OO being incorporated into other languages. The language C++, for example, is an OO-version of C.

Today, OO appears in some guise in a number of languages, like Eiffel, C++, and, of course, Java, to name just a few. Don't expect OO to look exactly the same in all OO languages, but the basic ideas are the same.