Byte magazine

https://archive.org/details/byte-magazine-1986-08 articles on object oriented languages p.227 Larry Tesler "... certain kind of enhancements can be made simply by creating new object types as variations of existing ones."

see pages 162

162
rocedure invoked is fixed at compile time. This model of object-oriented programming can be improved. As presented thus far. the addition of a new type of object requires writing entirely new procedures for common operations such as Print. What's worse is that there will be a great deal of similarity between different Print methods. requiring continual rewrites of methods that differ slightly or not at all. This burden is likely to be so great that programmers would avoid the creation of new object types.

significantly reducing the practical usefulness of object-oriented programming systems. Inheritance is a mechanism that largely relieves programmers of this burden.

INHERITANCE Inheritance enables programmers to create classes and. therefore. objects that are specializations of other objects. For example. you might create an object. Trumpet. that is a specialization of a Brass! nstrument. which is a specialization of a WindInstrument. which is a specialization of Musicallnstrument. etc. A Trumpet · inherits behavior that is appropriate for Brassl nstruments. Windl nstruments. and M usical l nstruments. Creating a specialization of an existing class is called subclassing. The new class is a subclass of the existing class.

and the existing class is the superclass of the new class. The subclass inherits instance variables. class variables. and 142 BYTE • AUGUST 1 986 PROGRAMMING ELEMENTS methods from its superclass. The subclass may add instance variables. class variables. and methods that are appropriate to more specialized objects. In addition. a subclass may override or provide additional behavior to methods of a superclass. Methods are overridden when you provide a new method for an old method's selector.

The mechanism to add new behavior to an existing method tends to be language-dependent. In those languages most closely modeled after Smalltalk. this is accomplished by embedding a message-send to the pseudovariable super in the new definition of a method (see the text box "Pseudovariables" on page 1 44). For example. suppose you have an initialization method. initial ize. defined in a superclass. If a subclass adds some instance variables. x and y, that must also be initialized to zero. then both initialization behaviors will be exhibited by the following method: initial ize super initial ize. X +- y +- 0.

The initialization in the superclass is performed. followed by the added initialization behavior. Depending on the placement of the message-send to super. the new behavior may precede. follow. or surround the existing behavior.

Inheritance enables programmers to create new classes of objects by specifying the differences between a new class and an existing class instead of starting from scratch each time. A large amount of code can be reused this way. ADVANTAGES Object-oriented languages have many advantages over more traditional procedure-oriented languages. Information hiding and data abstraction increase reliability and help decouple procedural and representational specification from i mplementation.

Dynamic binding increases flexibility by permitting the addition of new classes of objects (data types) without having to modify existing code. Inheritance coupled with dynamic binding permits code to be reused. This (conti

172

 * "...An object is a package of data and procedures that belong together. Specifically, all constants and the contents of all variables are objects ...." 

Translation into English: An object is a metaphor for stuffing the procedures into the struct''(now called a class). Both the hash table and functions mapping them are still separate entities, with the term 'object' used to refer to either the data or the functions or the action of the functions mapping inputs to outputs and what is referred to will be context dependent or impossible to discern.''

You now know enough that we can explain more Smalltalk lingo. The terms "method" and "message selector" were invented while asking the question, "How do we select the method an object will use to respond to this message?" The answer is. "Use the selector to find the right method to execute:· If you talk to yourself while you read code (don't be bashfuL everyone does), then you need to know how to "talk" Smalltalk. The phrase height > 0 does exactly what you think it does. and you can pronounce it j ust the way you would in other languages ("height is greater than zero"), but it is really shorthand for "the object height receives the message greater-than with the argument zero:· When an object receives a message, it looks up the message name to see if it understands the message. If the message is found, it starts executing the method that tells how to respond to the message. Just as a Pascal procedure may call other procedures, a method may need to caJI other methods. The way to start another method is to send a message to an object. Sometimes you want to send a message to the same object that received the current message. How is that object named locaJiy? In other words, when a Smalltalk object talks to itself. what does it call itself? Why, self, naturally. Not surprisingly, messages to self are common. You can see them sprinkled throughout the program in listing 2a. When a piece of code happens to send a message to the same selector as the current method. the program is using recursion. The method moveDisk:to: in listing 2b includes a couple ' of new things. The System Transcript is a window on the screen. It behaves like a traditional character-oriented terminal. The object that represents the transcriptis held in the global variable, Transcript. The message cr tells the transcript to append a carriage return. The message show: takes a string as an argument and appends it to the transcript. It also redisplays the text in the transcript windo

links
Lost in space syndrome

oop

Noun

Nouns and verbs oop