CS 535 Object-Oriented Programming Spring Semester, 2003 Introduction |
||
---|---|---|
© 2003, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 21-Jan-03 |
Introduction
Goal
Understand how to use classes & objects in code
Syntax of language is easy
How to create code that is:
Main Idea in Object-Oriented Programming
Related data and operations belong together
Design Heuristic 3.3
Beware of classes with many public accessor methods
Many accessors indicate that related data and behavior are not being kept in one place
Kent Beck’s Indicators of Good Style
Once and only once
Don’t repeat
Why Smalltalk
Language |
Lines
of code/function point
|
Smalltalk |
21 |
Ada
95
|
49 |
Java |
53 |
C++ |
53 |
COBOL |
107 |
C |
128
|
Why Smalltalk
Learning Smalltalk
Some History 1967 Simula-67
Smalltalk Influences
Object-Oriented Programming
GUI
Versions of Smalltalk
VisualWorks
VisualAge for Smalltalk
Squeak
Dolphin
Smalltalk MT
Smalltalk X
Smallscript (.NET Smalltalk)
PocketSmalltalk
Smalltalk & Bytecode
Smalltalk is compiled to a bytecode for a virtual machine
Bytecode is same on all machines
VisualWorks has VM's for:
VisualWorks
Parts of VisualWorks
Executable Virtual Machine (visual, visual.exe)
Starting VisualWorks on Macintosh
Method 1
Starting VisualWorks on UNIX
Type:
VisualWorks on Rohan
Image requires ~9MegBytes of disk space
Copy /opt/smalltalk/vw7nc/image/visualnc.im to a local directory
Change permissions so you have write permission on the local copy
Set the VISUALWORK environment variable
visual imageName
Some VisualWorks Environment
VisualWorks uses three logical buttons
|
3-Button
|
2-Button |
1-Button |
Select |
Left
button
|
Left
Button
|
Button |
Operate |
Right
button
|
Right
button
|
Ctrl+Button |
Window |
Middle
button
|
Ctrl+Left
button
|
command+Button |
Windows on Startup
Launcher
Ivan Tomek’s Introduction is a good way to start to learn about Smalltalk
Lesson Runner
Workspace
Do it (ctrl-d)
Print it
Using the Transcript
Exiting from VisualWorks
Some Text Editing Short Cuts
Selection shortcuts (double click)
To select text, use the following double-click shortcuts.
Double-click at start or end of a window to select all text in the window.
Double-click at start of line to select the line. Does not work on the first line.
Double-click at end of line to select the line. Does on work on the last line.
Double-click just after an opening (or just before the closing) of ' or [ or ( or " selects all text surrounded by the symbols.
Double-click inside a word or selector to select the word or selector.Ctrl keysPress at the same time the control key and the second key to:
<Ctrl> f inserts ifFalse: into the text.
<Ctrl> t inserts ifTrue: into the text.
<Ctrl> g inserts := into the text.
<Ctrl> d inserts today's date into the text.
<Ctrl> s (search or find) finds the next instance of the string in your copy buffer (last copied or cut string)
<Ctrl> e (replace) opens a replace dialog
<Ctrl> a (find) opens a find dialog
<Ctrl> c is equivalent to Copy,
<Ctrl> z will Undo the most recent text change,
<Ctrl> v is equivalent to PasteESC keys
Press and release the ESC key then press the second key to:
ESC b changes the selected text to bold.
ESC i changes the selected text to italic.
ESC u underlines the selected text.
When the letter is uppercase (B, I, U), the effect is reversed: ESC U removes underline, etc.
ESC + increases the font size of the selected text
ESC - decreases font size of the selected text
ESC followed by < or ' or " or [ or ( adds surrounding < ' " [ ( to the selected text.
ESC followed by <tab> selects the text just typed in
ESC x removes style changes to current selection and returns to default font.
Alt keys are also used as menu accelerator keys. Since menu accelerator keys have priority the following keys may not work in all text windows.
<alt> a (again) repeats the last text change
<alt> A repeats the last text change for rest of text in window
<alt> c copies selected text into copy buffer
<alt> d (do it) compiles and executes selected text
<alt> f finds the next occurrence of the selected text
<alt> F finds the next occurrence of the text in the copy buffer
<alt> n finds the next occurrence of the selected text
<alt> p pastes the copy buffer into the current location
<alt> P pastes from the last 5 elements of copy buffer
<alt> z undoes the last edit
Copyright ©, All rights reserved.
2003 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
    visitors since 21-Jan-03