This book is written in the same clear and concise style that has made Winston's Java, C++, C, and LISP books popular among students and programmers who want to add new languages to their repertoires. Following the unique and well-received approach developed in his other books, the author here gets readers up and running quickly and effectively in Smalltalk. Each easily digested section of the book adds new capabilities to a short, yet representative Smalltalk program, and natural questions that arise in learning a new language are effectively answered in a natural order. Much of the book applies to all versions of Smalltalk; where a specific interface is needed, the examples refer to Smalltalk Express, a version of Smalltalk freely available on the Web from ParcPlace Systems. Throughout the book, Winston shows why Smalltalk is the language of choice when you need power tools for writing object-oriented programs or for building graphical user interfaces. 1. How this Book Teaches You the Language.
Why you should learn Smalltalk.
Methods versus functions.
Programming idioms and programming principles.
2. How To Experiment Using the Workspace and the Transcript. The workspace and the transcript.
Expressions, receivers, messages, and answers.
Methods and arguments.
Unary, binary, and keyword methods.
Method precedence.
Expression separation.
Strings.
Patterns and instantiation.
3. How To Write Arithmetic Expressions. Arithmetic messages.
Integer, floating-point, and rational numbers.
Absence of special precedence conventions for arithmetic.
Number-class conversion.
4. How To Define Simple Methods. Method definition.
The self object.
Returning from methods.
Blank insensitivity and case sensitivity.
Message cascading.
String concatenation.
Comments.
5. How To Define Methods with Parameters. Arguments and parameters.
Parameters and local scope.
6. How To Perform Tests using Predicates. Equal and not equal.
Greater than and less than.
Negation.
Class-membership predicates.
7. How To Write Conditional Expressions. Boolean expressions.
ifTrue: and ifFalse: messages.
Blocks.
8. How To Combine Boolean Expressions. & and |.
and: and or:.
9. How To Introduce Local Variables. Local-variable initialization and assignment.
The role of nil.
Local scope.
10. How To Benefit from Procedure Abstraction. Making programs easier to reuse, read, and debug.
Making programs easier to augment, improve, and change.
11. How To Create Classes and Instances. Instance variables, setters, and getters.
Derived attributes.
12. How To Define Classes that Inherit Instance Variables and Methods. Subclasses and superclasses.
Inheriting instance variables and methods.
Method overriding.
Class-membership predicates.
Polymorphism.
13. How To Define Instance-Creation Methods. Instance-creation methods and initializors.
Definition of new versions of new.
14. How To Benefit from Data Abstraction. Hiding implementation details.
Making programs easier write and maintain.
15. How To Design Classes and Class Hierarchies. Explicit representation.
The modularity principle.
The no-duplication principle.
The look-it-up principle.
The is-a versus has-a principle.
16. How To Write Iteration Statements. Iteration expressions.
whileTrue: and whileFalse: expressions.
timesRepeat: expressions.
17. How To Write Recursive Methods. Methods that use themselves recursively.
The base part and the recursion part.
Recursion versus iteration efficiency.
18. How To Store Values in Class Variables. Class variables and class-variable access.
Class-variable setters and getters.
19. How To Store Values in Dictionaries. The Smalltalk dictionary.
Creation of new dictionaries.
Pool dictionaries.
20. How To Work With Arrays. Manipulating arrays of numeric elements.
Iterating with elements as parameter values.
Iterating with numeric indexes as parameter values.
Combining array elements with inject:into:.
Arrays of arrays.
21. How To Work with Ordered Collections and Sorted Collections. Ordered collections of elements.
Iteration over ordered collections.
Bags and sets.
Sorted collections and sort blocks.
22. How To Create File Streams for Input and Output. Creating file streams.
Reading strings, integers, and floats from input streams.
Writing to output streams.
Closing streams.
23. How To Work with Characters and Strings. Strings and characters.
Reading lines from files.
Extracting characters from strings.
Converting strings to streams.
24. How To Produce Formatted Text. Understanding field widths and padding characters.
Determining the length of a string.
Creating strings with specified length and filler.
25. How To Use Sorted Collections in Simulations. System simulation.
Event queues.
Application classes.
26. How to Work with Dates and Times. Time and Date objects.
Time and date creation, manipulation, and comparison.
Use of dates in simulations.
27. How To Define Binary Methods. Defining binary methods.
Creating new classes for numberlike objects.
28. How to Use Debugging Tools. The walkback window.
The debugger.
The inspector.
The stepper.
Senders and implementers.
29. How to Program Defensively. Indicating definitions are expected.
Defining class predicates.
Announcing errors.
30. How to Exchange Software. Absence of text files.
Filing in and filing out.
The chunk-file format.
31. How To Create Points and Rectangles. Screen coordinate system.
Points and rectangles.
32. How To Draw Lines and To Display Text in Windows. View managers, top panes, and graph panes.
The createViews method.
The when:perform: method.
Pens, lines, and displaying text.
33. How To Use the Graphics Context to Alter Appearance. Using pens and graphics contexts.
Changing colors, widths, and fonts.
Drawing plain and filled polygons.
34. How To Use List Boxes to Select Instances. Creating list boxes.
Loading list boxes with elements.
Determining which element has been selected.
35. How To Connect Together Display Elements. Sending messages to named views.
Broadcasting messages to all views.
36. How To Display Menus and File Dialog Windows. Menu items, menus, and menu bars.
Access to files via file dialogs.
37. How To Develop a GUI using a GUI Builder. Entering the GUI builder.
Installing graphical elements.
Sizing and alignment.
Understanding events and callbacks.
38. How To Work with a Commercial Smalltalk. Understanding categories and protocols.
Filing out categories and protocols.
Reading and writing file-stream distinctions.
39. How To Work with the Model—Viewer—Controller Paradigm. Change and update messages.
Dependent parts and views.
40. How To Use VisualWork's Value Holders and Aspect Adapters. Using value holders to hold values.
Using aspect adapters to translate messages.
41. How To Use VisualWorks To Build Applications. Application models.
VisualWorks GUI Builder.
42. How To Use VisualWorks To Build Viewers and Controllers. Defining new viewers.
Defining new controllers.
Appendix A: The Calorie Application. Appendix B: Packaging Applications for Users. Appendix C: The VisualWorks GUI Builder. Appendix D: The VisualWorks Drawing Methods. Colophon. Index. 0201498278T04062001