Sep 17, 2000 - Dispatcher - message to a free taxi: 'Please go to Terminal 3B and wait ..... three classes (Cat, Cow, and Dog), and one instance of class Cow ...
Overview In this chapter, we will first show what Smalltalk looks like and then introduce the essential concepts of object-oriented problem solving and illustrate them on several examples. Some of these examples are real-world situations, others are taken from Smalltalk itself. The principle of object-oriented problem solving is the insight that many problems are best approached by constructing models of real-world situations. The basis of these models are interacting objects with well-defined properties and behaviors. Solving a problem using the object-oriented approach thus consists of identifying appropriate objects and describing the functions that they must be able to perform and the information that they must hold. A computer application can then be constructed by converting such a description into a programming language. Programming languages that provide facilities for constructing such descriptions are called object-oriented and Smalltalk is one their prime examples.
1.1 Introduction Since you are probably eager to start writing and executing programs, we will begin with a few examples of Smalltalk code. Example 1: Arithmetic operations The line (15 * 19) + (37 squared)
is a typical Smalltalk arithmetic expression and you can see that it multiplies two numbers and adds the result to the square of a third number. To test this code, start VisualWorks Smalltalk using the instructions given in your User’s Guide1. You will get a screen containing the VisualWorks launcher window shown in Figure 1.1. Click the Workspace button and VisualWorks will open the window shown on the left in Figure 1.2.
Workspace button Figure 1.1. VisualWorks launcher window. Enter the example code into the Workspace as if you were using a word processor as follows: Click the left mouse button inside the Workspace and enter the text making sure that it looks exactly like our example. Then ‘select’ the text as you would in a word processor Smalltalk provides several selection 1
All our illustrations use VisualWorks Smalltalk. Other Smalltalk dialects have different user interfaces and their extended libraries are different. Most of the features covered in this book however apply.
1
Introduction to Smalltalk - Chapter 1 - Object-oriented programming - essential concepts Ivan Tomek 9/17/00
shortcuts. For example, clicking twice at the beginning or at the end of the text ‘view’ of a Smalltalk selects all text in the view, and clicking twice at the beginning or at the end of a line selects the whole line.: Press the left button just before the start of the text and drag the cursor to the right across the text, releasing the button at the end. The text is now highlighted as in the center of Figure 1.2. Finally, press and hold down the second mouse button from the left and click the print it command in the displayed pop up menu2. Smalltalk will execute the code and print the result in the Workspace as in the right window in Figure 1.2.
Figure 1.2. Workspace window: initial state (left), with selected text of Example 1 (middle), and displaying the result (right). Example 2: Comparison of results of numeric expressions The line (1327 squared) < (153 * 20000)
is a typical test to determine whether a comparison of two expressions gives a yes or a no answer. Type it into the Workspace, select it3, and execute it with print it. The answer displayed in the Workspace will be either true or false because Smalltalk treats a comparison as a question: ‘Is it true that ...?’ Example 3: String comparison The line ‘abc’ < ‘xyz’
is a typical string comparison that determines whether the string on the left precedes the string on the right in alphabetical ordering. Guess what the result should be and test whether you guessed right. Example 4. A string operation As you are beginning to see, Smalltalk is designed to be easy to read. In fact, one of the original goals of Smalltalk designers was to create a programming language that even children could use. What do you think is the result of the following expression? ‘Smalltalk’ asUppercase
Test whether you guessed right. Example 5. Simple output 2
Since the leftmost button of the mouse is used to make selections, Smalltalk programmers call it the button. The next button displays a popup menu with operation commands such as print it and it is thus called the button. 3 Smalltalk provides several selection shortcuts. For example, clicking twice at the beginning or at the end of the text view selects all text in the view, and clicking twice at the beginning or at the end of a line selects the whole line.
2
Introduction to Smalltalk - Chapter 1 - Object-oriented programming - essential concepts Ivan Tomek 9/17/00
All Smalltalk code consists of ‘messages’ to ‘objects’ and this is why it is called object-oriented. Some of the messages used above include squared, factorial, and < and the objects include 27, 13, and ‘abc’. The Smalltalk library includes thousands of messages and you can easily create any number of your own, but all of them have one of three possible structures. You have seen two types of messages above (messages consisting of a single word such as squared, and messages consisting of a special symbol such as
Sep 17, 2000 - In this chapter, we will first show what Smalltalk looks like and then introduce the ... 1 All our illustrations use VisualWorks Smalltalk. ..... object-oriented programming but an everyday fact of life. ...... language students and co
... looked at addition: the second integer was sent to the first, which returned the sum. CHAPTER 7 â¡ LOOPING. 79. 4916_Ch07_CMP2 5/12/05 7:14 PM Page ...
the Kernel-Classes category. We'll talk a little ... class itself. To make all this talk of method dictionaries and instance variables clearer, take a look at the code in.
is applied in civil engineering areas such as transportation (truck and ...... First the physics and mathematics of the space segment will be given (without derivations). ...... Bugayevskiy, L.M. and Snyder, J.P., Map Projections: A Reference Manual,
the moment equation (Eq. (i)) if the support points A and B were on different ..... Equation (5.14) is a quadratic equation in H and may be solved for a specific ...
ÎIEEE 802.3/802.3u/802.3x. ÎAuto negotiation speed. ÎAuto MDI/MDI-X. Industrial Grade Reliability. ÎRelay output port support power failure, port break alarm.
Additionally, engineering and economic analyses of prefabrication processes and ... industry, artificial intelligence (AI) is required to generate instructions.
niques are particularly suitable for such purposes as: (1) collecting hand-cut, block ... to locate buried utilities or rebar, estimate pavement thickness, interpret shallow ..... tive text, graphs, and data presented in tabular and/or bulleted list
In general, solving a solid mechanics problem must satisfy equations of equilibrium (static or dynamic) ... The influence of the material is expressed by constitutive laws in six equations. ..... To obtain a solution for the full set of basic unknown
up to 2 colours (clear beige, dark beige colours) TBC .... This connector is located at the bottom of the transmission module and enable the connection to various.
The Civil Engineering Handbook, Second Edition ...... in a regression form that gives a direct solution for the inlet head given the discharge, the span and the ..... The elasticity of the liquid and of the pipe material need to be taken into account
must be undertaken. During this process, many engineering assumptions are routinely used in the ... Li-Hong Sheng. California Department of Transportation ...
Apr 9, 2018 - mulations in stress and strain space are both given. ... In the rate-independent elastoplastic theory with the yield surface in strain space, the ...
26.2 Geo-Environmental Containment Systems. Liners ⢠Low-Permeability .... waste itself or may originate from water that has infiltrated into the waste. ...... materials in domestic sewage, or solid or dissolved materials in irrigation return flows
Pdf at: http://www.iam.unibe.ch/~ducasse/WebPages/Fre. eBooks.html .... While Smalltalk syntax is simple it is not like C/C++/Java ... Squeak Class Library.
on similar sets of basic principles, yet they all differ in their precise in- terpretation of these principles. Moreover, if the prototype-based model advocates concrete ...
"structured programming," and people talked about it in much the same way .... The first attempt at object-oriented programming system was FLEX, the focus of.
compression ignition engine and few people remember its inventor or the ... This statement made in 1878 so impressed Diesel that from then on, the idea of a ...
In the past it was common practice to teach structural analysis and stress analysis, or theory of structures and strength of materials as they were frequently known ...
chapter briefly reviews DVLO theory, and then reviews some notable ..... different values of shear stress could be increased (drag reduction) or decreased.
... point was the. 1920s. With increased household incomes in North America and Europe ... In the postâWorld War II (WWII) era we saw a second boom in the manufacturing ... level of production automation, whose competitiveness will heavily depend .
structure, we examined fragmented bones from various museum collections and we collected Computed .... Tokio: National Science. Museum Monographs. p ...
The classical methods and tools used in signal processing are often ...... A: the matrix on which the search occurs. %. %. % ... tool for viewing the different planes.