Docsity

Thinking Object-Oriented, Lecture notes of Object Oriented Programming

Toggle sidebar
bg1
Chapter 1
Thinking Ob ject-Oriented
Although the fundamental features of what wenow call object-oriented program-
ming were invented in the 1960's, object oriented languages really came to the
attention of the computing public-at-large in the 1980's. Two seminal events
were the publication of a widely-read issue of
Byte
(August 1981) that described
the programming language Smalltalk, and the ๎˜Œrst international conference on
object-oriented programming languages and applications, held in Portland, Ore-
gon in 1986.
Now, almost twentyyears later, it is still the case that, as I noted in the ๎˜Œrst
edition of this book (in 1991):
Object-oriented programming (OOP) has become exceedingly pop-
ular in the past few years. Software producers rush to release object-
oriented versions of their products. Countless books and special is-
sues of academic and trade journals have appeared on the sub ject.
Students strive to list \experience in object-oriented programming"
on their r๎˜“esum๎˜“es. To judge from this frantic activity, object-oriented
programming is being greeted with even more enthusiasm than we
saw heralding earlier revolutionary ideas, such as \structured pro-
gramming" or \expert systems."
My intent in these ๎˜Œrst two chapters is to investigate and explain the ba-
sic principles of object-oriented programming, and in doing so to illustrate the
following two propositions:
๎˜
OOP is a revolutionary idea, totally unlikeanything that has come b efore
in programming.
๎˜
OOP is an evolutionary step, following naturally on the heels of earlier
programming abstractions.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Thinking Object-Oriented and more Lecture notes Object Oriented Programming in PDF only on Docsity!

Chapter 1

Thinking Ob ject-Oriented

Although the fundamental features of what we now call ob ject-oriented program- ming were invented in the 1960's, ob ject oriented languages really came to the attention of the computing public-at-large in the 1980's. Two seminal events were the publication of a widely-read issue of Byte (August 1981) that describ ed the programming language Smalltalk, and the rst international conference on ob ject-oriented programming languages and applications, held in Portland, Ore- gon in 1986. Now, almost twenty years later, it is still the case that, as I noted in the rst edition of this b o ok (in 1991):

Ob ject-oriented programming (OOP) has b ecome exceedingly p op- ular in the past few years. Software pro ducers rush to release ob ject- oriented versions of their pro ducts. Countless b o oks and sp ecial is- sues of academic and trade journals have app eared on the sub ject. Students strive to list \exp erience in ob ject-oriented programming" on their resumes. To judge from this frantic activity, ob ject-oriented programming is b eing greeted with even more enthusiasm than we saw heralding earlier revolutionary ideas, such as \structured pro- gramming" or \exp ert systems."

My intent in these rst two chapters is to investigate and explain the ba- sic principles of ob ject-oriented programming, and in doing so to illustrate the following two prop ositions:

 OOP is a revolutionary idea, totally unlike anything that has come b efore in programming.

 OOP is an evolutionary step, following naturally on the heels of earlier programming abstractions.

2 CHAPTER 1. THINKING OBJECT-ORIENTED

1.1 Why Is OOP Popular?

There are a numb er of imp ortant reasons why in the past two decades ob ject- oriented programming has b ecome the dominant programming paradigm. Ob ject- oriented programming scales very well, from the most trivial of problems to the most complex tasks. It provides a form of abstraction that resonates with tech- niques p eople use to solve problems in their everyday life. And for most of the dominant ob ject-oriented languages there are an increasingly large numb er of libraries that assist in the development of applications for many domains. Ob ject-oriented programming is just the latest in a long series of solutions that have b een prop osed to help solve the \software crisis." At heart, the software crisis simply means that our imaginations, and the tasks we would like to solve with the help of computers, almost always outstrip our abilities. But while ob ject-oriented techniques do facilitate the creation of complex software systems, it is imp ortant to rememb er that OOP is not a panacea. Pro- gramming a computer is still one of the most dicult tasks ever undertaken by humans; b ecoming pro cient in programming requires talent, creativity, intelli- gence, logic, the ability to build and use abstractions, and exp erience{even when the b est of to ols are available. I susp ect another reason for the particular p opularity of languages such as C++^ and Delphi (as opp osed to languages such as Smalltalk and Beta) is that managers and programmers alike hop e that a C or Pascal programmer can b e changed into a C++^ or Delphi programmer with no more e ort than the addi- tion of a few characters to their job title. Unfortunately, this hop e is a long way from b eing realized. Ob ject-oriented programming is a new way of think- ing ab out what it means to compute, ab out how we can structure information and communicate our intentions b oth to each other and to the machine. To b ecome pro cient in ob ject-oriented techniques requires a complete reevaluation of traditional software development.

1.2 Language and Thought

\Human b eings do not live in the ob jective world alone, nor alone in the world of so cial activity as ordinarily understo o d, but are very much at the mercy of the particular language which has b ecome the medium of expression for their so ciety. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving sp eci c problems of communication or re ection. The fact of the matter is that the `real world' is to a large extent unconsciously built up on the language habits of the group.... We see and hear and otherwise exp erience very largely as we do b ecause the language habits of our community predisp ose certain choices of interpretation." Edward Sapir (quoted in [Whorf 1956 ])

4 CHAPTER 1. THINKING OBJECT-ORIENTED

1 n

m m

t c g^ a g

z }| { t c g^ a g

z }| {

The programmer dutifully sat down and wrote a simple and straightforward FORTRAN program something like the following:

DO 10 I = 1, N-M DO 10 J = 1, N-M FOUND = .TRUE. DO 20 K = 1, M 20 IF X[I+K-1] .NE. X[J+K-1] THEN FOUND = .FALSE. IF FOUND THEN ... 10 CONTINUE

He was somewhat disapp ointed when trial runs indicated his program would need many hours to complete. He discussed his problem with a second student, who happ ened to b e pro cient in the programming language APL, who said that she would like to try writing a program for this problem. The rst student was dubious; after all, FORTRAN was known to b e one of the most \ecient" programming languages{it was compiled, and APL was only interpreted. So it was with a certain amount of incredulity that he discovered that the APL programmer was able to write an algorithm that worked in a matter of minutes, not hours. What the APL programmer had done was to rearrange the problem. Rather than working with a vector of N elements, she reorganized the data into a matrix with roughly N rows and M columns:

x 1 x 2 ... xm x 2 x 3 ... xm+ ... ... xnm ... ... xn 1 xn(m1) ... xn 1 xn

She then ordered this matrix by rows (that is, treated each row as a unit, moving entire rows during the pro cess of sorting). If any pattern was rep eated, then two adjacent rows in the ordered matrix would have identical values.

... T G G A C C T G G A C C ...

It was a trivial matter to check for this condition. The reason the APL program was faster had nothing to do with the sp eed of APL versus FORTRAN; it was simply that the FORTRAN program employed an algorithm that was

1.2. LANGUAGE AND THOUGHT 5

O (M  N 2 ), whereas the sorting solution used by the APL programmer required approximately O (M  N log N ) op erations. The p oint of this story is not that APL is in any way a \b etter" programming language than FORTRAN, but that the APL programmer was naturally led to discover an entirely di erent form of solution. The reason, in this case, is that lo ops are very dicult to write in APL whereas sorting is trivial{it is a built-in op erator de ned as part of the language. Thus, b ecause the sorting op eration is so easy to p erform, go o d APL programmers tend to lo ok for novel applications for it. It is in this manner that the programming language in which the solution is to b e written directs the programmer's mind to view the problem in a certain way.

1.2.3 Church's Conjecture and the Whorf Hyp othesis *

The assertion that the language in which an idea is expressed can in uence or direct a line of thought is relatively easy to b elieve. However, a stronger conjec- ture, known in linguistics as the Sapir-Whorf hyp othesis, go es much further and remains controversial. The Sapir-Whorf hyp othesis asserts that it may b e p ossible for an individual working in one language to imagine thoughts or to utter ideas that cannot in any way b e translated, cannot even b e understo o d, by individuals op erating in a di erent linguistic framework. According to advo cates of the hyp othesis, this can o ccur when the language of the second individual has no equivalent words and lacks even concepts or categories for the ideas involved in the thought. It is interesting to compare this p ossibility with an almost directly opp osite concept from computer science{namely, Church's conjecture. Starting in the 1930s and continuing through the 1940s and 1950s there was a great deal of interest within the mathematical and nascent computing commu- nity in a variety of formalisms that could b e used for the calculation of functions. Examples are the notations prop osed by Church [Church 1936 ], Post [Post 1936 ], Markov [Markov 1951 ], Turing [Turing 1936 ], Kleene [Kleene 1936 ] and others. Over time a numb er of arguments were put forth to demonstrate that many of these systems could b e used in the simulation of other systems. Often, such arguments for a pair of systems could b e made in b oth directions, e ectively showing that the systems were identical in computation p ower. The sheer num- b er of such arguments led the logician Alonzo Church to pronounce a conjecture that is now asso ciated with his name:

Church's Conjecture: Any computation for which there exists an e ective pro cedure can b e realized by a Turing machine.

By nature this conjecture must remain unproven and unprovable, since we have no rigorous de nition of the term \e ective pro cedure." Nevertheless, no

(^0) Section headings followed by an asterisk indicate optional material.

1.3. A NEW PARADIGM 7

sp ecies

genus

family

order

class

phylum

kingdom (^) Animalia

Mollusca Chordata

Gastrop o da Reptilla (^) Mammalia

Mesogastrop o da (^) Predentata Primates

Cypraeidae Ceratopsidae (^) Hominidae

Cypraea Triceratops (^) Homo

tigris (^) horridus sapiens

Q
Q

QQs

@@R

Figure 1.1: The Linnn Inheritance Hierarchy

It is interesting to examine the de nition of the word \paradigm." The following is from the American Heritage Dictionary of the English Language:

par a digm n. 1. A list of all the in ectional forms of a word taken as an illustrative example of the conjugation or declension to which it b elongs. 2. Any example or mo del. [Late Latin paradgma, from Greek paradeigma, mo del, from paradeiknunai, to compare, exhibit.]

At rst blush, the conjugation or declension of Latin words would seem to have little to do with computer programming languages. To understand the connection, we must note that the word was brought into the mo dern vo cab- ulary through an in uential b o ok, The Structure of Scienti c Revolutions, by the historian of science Thomas Kuhn [Kuhn 1970 ]. Kuhn used the term in the second form, to describ e a set of theories, standards, and metho ds that together represent a way of organizing knowledge{that is, a way of viewing the world. Kuhn's thesis was that revolutions in science o ccur when an older paradigm is reexamined, rejected, and replaced by another. It is in this sense, as a mo del or example and as an organizational ap- proach, that Rob ert Floyd used the term in his 1979 ACM Turing Award lec- ture [Floyd 1979 ], \The Paradigms of Programming." A programming paradigm is a way of conceptualizing what it means to p erform computation and how tasks to b e carried out on a computer should b e structured and organized. Although new to computation, the organizing technique that lies at the heart

8 CHAPTER 1. THINKING OBJECT-ORIENTED

of ob ject-oriented programming can b e traced back at least as far as Carolus Lin- nus (1707{1778) (Figure 1.1). It was Linnus, you will recall, who categorized biological organizisms using the idea of phylum, genus, sp ecies, and so on. Paradoxically, the style of problem solving emb o died in the ob ject-oriented technique is frequently the metho d used to address problems in everyday life. Thus, computer novices are often able to grasp the basic ideas of ob ject-oriented programming easily, whereas p eople who are more computer literate are often blo cked by their own preconceptions. Alan Kay, for example, found that it was often easier to teach Smalltalk to children than to computer profession- als [Kay 1977 ]. In trying to understand exactly what is meant by the term object-oriented programming, it is useful to examine the idea from several p ersp ectives. The next few sections outline two asp ects of ob ject-oriented programming; each illustrates a particular reason that this technique should b e considered an imp ortant new to ol.

1.4 A Way of Viewing the World

To illustrate some of the ma jor ideas in ob ject-oriented programming, let us consider rst how we might go ab out handling a real-world situation and then ask how we could make the computer more closely mo del the techniques employed. Supp ose an individual named Chris wishes to send owers to a friend named Robin, who lives in another city. Because of the distance, Chris cannot simply pick the owers and take them to Robin in p erson. Nevertheless, it is a task that is easily solved. Chris simply walks to a nearby ower shop, run by a orist named Fred. Chris will tell Fred the kinds of owers to send to Robin, and the address to which they should b e delivered. Chris can then b e assured that the owers will b e delivered exp ediently and automatically.

1.4.1 Agents and Communities

At the risk of b elab oring a p oint, let us emphasize that the mechanism that was used to solve this problem was to nd an appropriate agent (namely, Fred) and to pass to this agent a message containing a request. It is the responsibility of Fred to satisfy the request. There is some method{some algorithm or set of op erations{used by Fred to do this. Chris do es not need to know the particular metho d that Fred will use to satisfy the request; indeed, often the p erson making a request do es not want to know the details. This information is usually hidden from insp ection. An investigation, however, might uncover the fact that Fred delivers a slightly di erent message to another orist in the city where Robin lives. That orist, in turn, p erhaps has a sub ordinate who makes the ower arrangement. The orist then passes the owers, along with yet another message, to a delivery p erson, and so on. Earlier, the orist in Robin's city had obtained her owers from a

10 CHAPTER 1. THINKING OBJECT-ORIENTED

means by which the request will b e honored. There is another principle, all to o human, that we see is implicit in message passing. If there is a task to p erform, the rst thought of the client is to nd someb o dy else he or she can ask to do the work. This second reaction often b ecomes atrophied in many programmers with extensive exp erience in conventional techniques. Frequently, a dicult hurdle to overcome is the idea in the programmer's mind that he or she must write everything and not use the services of others. An imp ortant part of ob ject-oriented programming is the development of reusable comp onents, and an imp ortant rst step in the use of reusable comp onents is a willingness to trust software written by others.

Messages versus Pro cedure Calls

Information hiding is also an imp ortant asp ect of programming in conventional languages. In what sense is a message di erent from, say, a pro cedure call? In b oth cases, there is a set of well-de ned steps that will b e initiated following the request. But, there are two imp ortant distinctions.

The rst is that in a message there is a designated receiver for that message; the receiver is some ob ject to which the message is sent. In a pro cedure call, there is no designated receiver.

The second is that the interpretation of the message (that is, the metho d used to resp ond to the message) is determined by the receiver and can vary with di erent receivers. Chris could give a message to a friend named Elizab eth, for example, and she will understand it and a satisfactory outcome will b e pro duced (that is, owers will b e delivered to their mutual friend Robin). However, the metho d Elizab eth uses to satisfy the request (in all likeliho o d, simply passing the request on to Fred) will b e di erent from that used by Fred in resp onse to the same request.

If Chris were to ask Kenneth, a dentist, to send owers to Robin, Kenneth may not have a metho d for solving that problem. If he understands the request at all, he will probably issue an appropriate error diagnostic.

Let us move our discussion back to the level of computers and programs. There, the distinction b etween message passing and pro cedure calling is that, in message passing, there is a designated receiver, and the interpretation{the selection of a metho d to execute in resp onse to the message{may vary with di erent receivers. Usually, the sp eci c receiver for any given message will not b e known until run time, so the determination of which metho d to invoke cannot b e made until then. Thus, we say there is late binding b etween the message (function or pro cedure name) and the co de fragment (metho d) used to resp ond to the message. This situation is in contrast to the very early (compile-time or link-time) binding of name to co de fragment in conventional pro cedure calls.

1.4. A WAY OF VIEWING THE WORLD 11

1.4.3 Resp onsibilities

A fundamental concept in ob ject-oriented programming is to describ e b ehavior in terms of responsibilities. Chris's request for action indicates only the desired out- come ( owers sent to Robin). Fred is free to pursue any technique that achieves the desired ob jective, and in doing so will not b e hamp ered by interference from Chris. By discussing a problem in terms of resp onsibilities we increase the level of abstraction. This p ermits greater independence b etween ob jects, a critical factor in solving complex problems. The entire collection of resp onsibilities asso ciated with an ob ject is often describ ed by the term protocol. A traditional program often op erates by acting on data structures, for exam- ple changing elds in an array or record. In contrast, an ob ject oriented program requests data structures (that is, ob jects) to p erform a service. This di erence b etween viewing software in traditional, structured terms and viewing it from an ob ject-oriented p ersp ective can b e summarized by a twist on a well-known quote:

Ask not what you can do to your data structures, but rather ask what your data structures can do for you.

1.4.4 Classes and Instances

Although Chris has only dealt with Fred a few times, Chris has a rough idea of the transaction that will o ccur inside Fred's ower shop. Chris is able to make certain assumptions based on previous exp erience with other orists, and hence Chris can exp ect that Fred, b eing an instance of this category, will t the general pattern. We can use the term Florist to represent the category (or class) of all orists. Let us incorp orate these notions into our next principle of ob ject-oriented programming:

All ob jects are instances of a class. The metho d invoked by an ob ject in resp onse to a message is determined by the class of the receiver. All ob jects of a given class use the same metho d in resp onse to similar messages.

1.4.5 Class Hierarchies{Inheritance

Chris has more information ab out Fred{not necessarily b ecause Fred is a orist but b ecause he is a shopkeep er. Chris knows, for example, that a transfer of money will b e part of the transaction, and that in return for payment Fred will o er a receipt. These actions are true of gro cers, stationers, and other shopkeep ers. Since the category Florist is a more sp ecialized form of the category Shopkeep er, any knowledge Chris has of Shopkeep ers is also true of Florists and hence of Fred.

1.4. A WAY OF VIEWING THE WORLD 13

Material Objects ^       Animal Plant

Mammal Flower

Dog Human Platypus

HH
HH
HH
HH
HH
HH

Shopkeep er Artist Dentist

XXXXXXXXXXXXX
X

Carnation

B
B
BB
HH
HH
HH
H

Florist Potter

Fido Fred Elizabeth Kenneth Phyl Robin's owers

Figure 1.4: { A class hierarchy for various material ob jects.

the tree, and more sp eci c classes, and nally individuals, are listed near the b ottom. Figure 1.4 shows this class hierarchy for Fred. This same hierarchy also includes Elizab eth, Chris's dog Fido, Phyl the platypus who lives at the zo o, and the owers the Chris is sending to Robin. Notice that the structure and interpretation of this typ e of diagram is similar to the biological hierarchy presented earlier in Figure 1.1. Information that Chris p ossess ab out Fred b ecause Fred is an instance of class Human is also applicable to Elizab eth, for example. Information that Chris knows ab out Fred b ecause he is a Mammal is applicable to Fido as well. Information ab out all memb ers of Material Object is equally applicable to Fred and to his owers. We capture this in the idea of inheritance:

Classes can b e organized into a hierarchical inheritance structure. A child class (or subclass) will inherit attributes from a parent class higher in the tree. An abstract parent class is a class (such as Mam-

14 CHAPTER 1. THINKING OBJECT-ORIENTED

mal) for which there are no direct instances; it is used only to create sub classes.

1.4.6 Metho d Binding and Overriding

Phyl the platypus presents a problem for our simple organizing structure. Chris knows that mammals give birth to live children, and Phyl is certainly a Mammal, yet Phyl (or rather his mate Phyllis) lays eggs. To accommo date this, we need to nd a technique to enco de exceptions to a general rule. We do this by decreeing that information contained in a sub class can override information inherited from a parent class. Most often, implementations of this approach takes the form of a metho d in a sub class having the same name as a metho d in the parent class, combined with a rule for how the search for a metho d to match a sp eci c message is conducted:

The search for a metho d to invoke in resp onse to a given message b e- gins with the class of the receiver. If no appropriate metho d is found, the search is conducted in the parent class of this class. The search continues up the parent class chain until either a metho d is found or the parent class chain is exhausted. In the former case the metho d is executed; in the latter case, an error message is issued. If metho ds with the same name can b e found higher in the class hierarchy, the metho d executed is said to override the inherited b ehavior.

Even if a compiler cannot determine which metho d will b e invoked at run time, in many ob ject-oriented languages, such as Java, it can determine whether there will b e an appropriate metho d and issue an error message as a compile-time error diagnostic rather than as a run-time message. The fact that b oth Elizab eth and Fred will react to Chris's messages, but use di erent metho ds to resp ond, is one form of polymorphism. As explained, that Chris do es not, and need not, know exactly what metho d Fred will use to honor the request is an example of information hiding.

1.4.7 Summary of Ob ject-Oriented Concepts

Alan Kay, considered by some to b e the father of ob ject-oriented programming, identi ed the following characteristics as fundamental to OOP [Kay 1993 ]:

  1. Everything is an object.
  2. Computation is p erformed by ob jects communicating with each other, re- questing that other ob jects p erform actions. Ob jects communicate by send- ing and receiving messages. A message is a request for action bundled with whatever arguments may b e necessary to complete the task.
  3. Each ob ject has its own memory, which consists of other ob jects.
16 CHAPTER 1. THINKING OBJECT-ORIENTED

a[1]: a[2]: a[3]: a[4]: 4 6 2 4

x: 47

i: j: 2 3

Figure 1.5: { Visualization of imp erative programming.

another, and sets them moving. This is almost identical to the average ob ject- oriented program, in which the user describ es what the various entities in the universe for the program are, and how they will interact with one another, and nally sets them in motion. Thus, in ob ject-oriented programming, we have the view that computation is simulation [Kay 1977 ].

1.5.1 The Power of Metaphor

An easily overlo oked b ene t to the use of ob ject-oriented techniques is the p ower of metaphor. When programmers think ab out problems in terms of b ehaviors and resp onsibilities of ob jects, they bring with them a wealth of intuition, ideas, and understanding from their everyday exp erience. When envisioned as pigeon holes, mailb oxes, or slots containing values, there is little in the programmer's background to provide insight into how problems should b e structured. Although anthrop omorphic descriptions such as the quote by Ingalls may strike some p eople as o dd, in fact they are a re ection of the great exp ositive p ower of metaphor. Journalists make use of metaphor every day, as in the following description of ob ject-oriented programming from Newsweek:

Unlike the usual programming metho d{writing software one line at a time{NeXT's \ob ject-oriented" system o ers larger building blo cks that develop ers can quickly assemble the way a kid builds faces on Mr. Potato Head.

Possibly this feature, more than any other, is resp onsible for the frequent ob- servation that it is sometimes easier to teach ob ject-oriented programming con- cepts to computer novices than to computer professionals. Novice users quickly

1.5. COMPUTATION AS SIMULATION * 17

Figure 1.6: Mr. Potato Head, an Ob ject-Oriented Toy

1.6. A BRIEF HISTORY * 19

programming language develop ed by his group was named Smalltalk. This lan- guage evolved through several revisions during the decade. A widely read 1981 issue of Byte magazine, in which the quote by Ingalls presented earlier app ears, did much to p opularize the concepts develop ed by Kay and his team at Xerox. Roughly contemp oraneous with Kays work was another pro ject b eing con- ducted on the other side of the country. Bjarne Stroustrup, a researcher at Bell Lab oratories who had learned Simula while completing his do ctorate at Cam- bridge University in England, was developing an extension to the C language that would facilitate the creation of ob jects and classes [Stroustrup 82 ]. This was to eventually evolve into the language C++ [Stroustrup 1994 ]. With the dissemination of information on these and other similar pro jects, an explosion of research in ob ject-oriented programming techniques b egan. By the time of the rst ma jor conference on ob ject-oriented programming, in 1986, there were literally dozens of new programming languages vying for acceptance. These included Ei el [Meyer 1988a], Ob jective-C [Cox 1986 ], Actor [Actor 1987 ], Ob ject Pascal, and various Lisp dialects. In the two decades since the 1986 OOPSLA conference, ob ject-oriented pro- gramming has moved from b eing revolutionary to b eing mainstream, and in the pro cess has transformed a ma jor p ortion of the eld of computer science as a whole.

Chapter Summary

 Ob ject-oriented programming is not simply a few new features added to programming languages. Rather, it is a new way of thinking ab out the pro cess of decomp osing problems and developing programming solutions.

 Ob ject-oriented programming views a program as a collection of lo osely connected agents, termed objects. Each ob ject is resp onsible for sp eci c tasks. It is by the interaction of ob jects that computation pro ceeds. In a certain sense, therefore, programming is nothing more or less than the simulation of a mo del universe.

 An ob ject is an encapsulation of state (data values) and behavior (op- erations). Thus, an ob ject is in many ways similar to sp ecial purp ose computer.

 The b ehavior of ob jects is dictated by the ob ject class. Every ob ject is an instance of some class. All instances of the same class will b ehave in a similar fashion (that is, invoke the same metho d) in resp onse to a similar request.

 An ob ject will exhibit its b ehavior by invoking a metho d (similar to ex- ecuting a pro cedure) in resp onse to a message. The interpretation of the message (that is, the sp eci c metho d used) is decided by the ob ject and may di er from one class of ob jects to another.

20 CHAPTER 1. THINKING OBJECT-ORIENTED

 Classes can b e linked to each other by means of the notion of inheritance. Using inheritance, classes are organized into a hierarchical inheritance tree. Data and b ehavior asso ciated with classes higher in the tree can also b e accessed and used by classes lower in the tree. Such classes are said to inherit their b ehavior from the parent classes.

 Designing an ob ject oriented program is like organizing a community of in- dividuals. Each memb er of the community is given certain resp onsibilities. The achievement of the goals for the community as a whole come ab out through the work of each memb er, and the interactions of memb ers with each other.

 By reducing the interdep endency among software comp onents, ob ject- oriented programming p ermits the development of reusable software sys- tems. Such comp onents can b e created and tested as indep endent units, in isolation from other p ortions of a software application.

 Reusable software comp onents p ermit the programmer to deal with prob- lems on a higher level of abstraction. We can de ne and manipulate ob jects simply in terms of the messages they understand and a description of the tasks they p erform, ignoring implementation details.

Further Reading

I noted earlier that many consider Alan Kay to b e the father of ob ject-oriented programming. Like most simple assertions, this one is only somewhat supp ort- able. Kay himself [Kay 1993 ] traces much of the in uence on his development of Smalltalk to the earlier computer programming language Simula, develop ed in Scandinavia in the early 1960s [Dahl 1966 , Kirkerud 1989 ]. A more accurate his- tory would b e that most of the principles of ob ject-oriented programming were fully worked out by the develop ers of Simula, but that these would have b een largely ignored by the profession had they not b een rediscovered by Kay in the creation of the Smalltalk programming language. A widely read 1981 issue of Byte magazine did much to p opularize the concepts develop ed by Kay and his team at Xerox PARC. The term \software crisis" seems to have b een coined by Doug McIlroy at a 1968 NATO conference on software engineering. It is curious that we have b een in a state of crisis now for more than half the life of computer science as a discipline. Despite the end of the Cold War, the end of the software crisis seems to b e no closer now than it was in 1968. See, for example, Gibb's article \Software's Chronic Crisis" in the Septemb er 1994 issue of Scienti c American [Gibbs 1994 ]. To some extent, the software crisis may b e largely illusory. For example, tasks considered exceedingly dicult ve years ago seldom seem so daunting to day. It is only the tasks that we wish to solve today that seem, in comparison, to b e nearly imp ossible, which seems to indicate that the eld of software development has, indeed, advanced steadily year by year.