← Object-Oriented Programming for the Macintosh

Object-Oriented Programming for the Macintosh

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

HAYDEN Macintosh Library BOOKS Object-Oriented Programming for the Macintosh™ Kurt J. Schmucker

A book cover with a dark gradient background, orange bands at top and bottom, a teal wavy line, and a framed illustration of a beige Macintosh computer with keyboard and mouse in front of an archway showing a blue ocean scene and a grey sphere on a red floor.

Reading notes: Stylized script 'Macintosh Library' in the top banner is partly decorative and read as such; spelling taken from the title block. Small trademark symbol after Macintosh in title is rendered as ™.

Printed product names
Macintosh
Languages
English
PDF page 1

HAYDEN Macintosh Library BOOKS Object-Oriented Programming for the Macintosh™ Kurt J. Schmucker

Book cover with a dark background, an orange top band and orange bottom band, a teal wavy line, and a framed illustration of a beige Macintosh computer with keyboard and mouse on a red table beside a silver sphere, with an arched window showing a sea and island scene.

Reading notes: The 'Macintosh Library' script logo at top is stylized and was transcribed as printed; the word 'Macintosh' in the logo is rendered in script and may be read with some uncertainty.

Printed product names
Macintosh
Languages
English
PDF page 2

Object-Oriented Programming for the Macintosh™

Object-Oriented Programming for the Macintosh™ KurtJ.Schlllucker [JJ Hayden Book Company A DIVISION DF HAYDEN PUBLISHING COMPANY, INC. HASBROUCK HEIGHTS, NEW JERSEY

Reading notes: The author line 'KurtJ.Schlllucker' appears garbled and may be an OCR error for a different spelling; verify against the cover. The short mark '[JJ' between the author and publisher may be a logo or symbol rather than text. The source is a book cover rather than an advertisement, so no advertised products or prices were listed. No printed dates or years were visible in the supplied copy.

Languages
English
PDF page 3

To Karen Acquisitions Editor: BILL GROUT Production Editor: RONNIE GROFF Composition and production: TECHART, SAN FRANCISCO Cover photo-illustration: RON MORECRAFT Cover design: JIM BERNARD Printed and bound by: COMMAND WEB OFFSET, INC. Library of Congress Cataloging-in-Publication Data Schmucker; Kurt J. Object-oriented programming for the Macintosh. Includes index. 1. Macintosh IComputer)-Programming. I. Title. QA76.8.M3S35 1986 005.265 86-7668 ISBN 0-8104-6565-5 Copyright © 1986 by Productivity Products International, Inc. All rights reserved. No part of this book may be reprinted, or reproduced, or utilized in any form or by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying and recording, or in any information storage and retrieval system, without permission in writing from the Publisher; with the exception that programs may be stored and retrieved electronically for personal use. Printed in the United States of America 1 2 3 4 5 6 7 8 9 Printing 86 87 88 89 90 91 92 93 94 Year Macintosh is a trademark of Macintosh Laboratory, Inc., licensed to Apple Computer Inc., neither of which is affiliated with Hayden Book Company. QuickDraw, Finder; Inside Macintosh, MacPaint, MacDraw, MacProject, Switcher; MacApp, Object Pascal, MacTerminal, Clascal, Lisa Toolkit, Object Assembler; and Font/DA Mover are trademarks of Apple Computer Inc. Several figures are used by permission of Apple. The names of all other computer programs, computer programming languages, and computers included herein are registered trademarks of their makers.

Reading notes: Copyright line and year lists may be partially truncated in extraction Some trademark names use inconsistent spacing and punctuation in the source

Printed dates
1986 · 86-7668 · 86 · 87 · 88 · 89 · 90 · 91 · 92 · 93 · 94
Languages
English
PDF page 4

Foreword Macintosh applications are easy to use, but until recently they were difficult to program. Their nontraditional user interface refused to yield to traditional software engineering techniques. Now, a new tech- nique has emerged to make Macintosh application development easier. It is called object-oriented programming. In the 1960s, Kristen Nygaard and Ole-Johan Dahl of the Norwegian Computing Center needed a language to cope with complex simulation problems. Many simulations involve the interplay of objects such as gas molecules and walls, or customers, tellers, and bank accounts. Nygaard and Dahl decided to make the object concept an explicit feature in their programming language, Simula. Simula makes it easy to model a portion of the world as an interacting set of objects. Simula never attained the popularity of competitors like Fortran, Pascal, and C, but its ideas have been adopted by many language design- ers. The expanding roster of object-oriented languages includes Planner, Smalltalk, Objective-C, LOOPS, Object Pascal, and C + + . A few of these languages are becoming available on the Macintosh. For example, my group at Apple has developed versions of Smalltalk-80 and Object Pascal. Kriya Systems has developed Neon, and other companies have indicated that they plan to introduce object-oriented language compilers and inter- preters in the near future. iii

Printed dates
1960s
Languages
English
PDF page 5

iv Foreword Object-oriented programming is still an evolving discipline. Pro- fessor Nygaard himself is currently participating in the design of a new object-oriented language, Beta. Researchers around the world, including several at Apple, are investigating new variations of the technique, includ- ing visual programming languages that allow certain simple programs to be implemented in hours instead of days. The subject of the book you are holding is not research but practical application development. Larry Rosenstein, Scott Wallace, Ken Doyle, and other Macintosh experts at Apple have devised a model of the "typical" Macintosh application structured in terms of objects such as windows, documents, and commands. They have embodied their model in a soft- ware library called MacApp. If you choose to use MacApp to develop a Macintosh application, it will probably save you months of effort as com- pared with the traditional approach. With MacApp, you need only code the differences between your specific application and the "typical" one MacApp models. In addition, the use of MacApp will make your applica- tion more consi.stent with Apple's user interface standards and will make it easier for you to meet customer expectations of reliability and error recovery. MacApp programs can be written in various high-level lan- guages as well as in Assembler. This book includes a thorough introduc- tion to MacApp and some of its languages. MacApp is not the first object-oriented software library to model a window-oriented user interface. During the 1970s, Alan Kay's Leaming Research Group (LRG) at Xerox Palo Alto Research Center developed a system and language called Smalltalk that used a window-oriented user interface and included an object-oriented library. LRG scientists led by Dan Ingalls developed several versions of Smalltalk, starting with a chil- dren's language called Smalltalk-72 and culminating in a professional programmer's version known as Smalltalk-80. The user interface library of Smalltalk-80 is called Model-View-Controller or MVC. To my knowledge, this book is the first to explain the concepts of MVC as they are expressed in the standard Smalltalk-80 release. It also describes the Lisa ToolKit, a predecessor of MacApp that ran on the Lisa, and provides excellent sum- maries of Neon, ExperCommonLisp, Object Logo, and Objective-C. MacApp has been available as a Lisa-to-Macintosh cross-develop- ment system since February 1985. At the time of this writing, Apple is testing a Macintosh standalone version in preparation for release to a wider user community. The company will provide a manual, sample programs, and reference material with the MacApp release, but is count- ing on independent authors to provide tutorials. The book in your hands is unique in that the author took an early interest in MacApp and worked closely with Apple for over a year to gather information for his text. His book is written for experienced programmers, and assumes some knowl- edge of Pascal and an acquaintance with the user interface of the Macin-

Reading notes: Possible OCR artifact 'consi.stent' and 'Leaming' in the source text Preface-style text appears to be a foreword with no primary heading

Printed product names
MacApp · Smalltalk · Smalltalk-72 · Smalltalk-80 · Lisa ToolKit · Neon · ExperCommonLisp · Object Logo · Objective-C · Beta · Model-View-Controller · MVC · Lisa · Macintosh · Assembler · Pascal
Printed dates
1970s · February 1985
Languages
English
PDF page 6

V Foreword tosh. The author has actually implemented an interesting Macintosh application, QuadWorld, and uses it to illustrate the concepts he teaches. Object-oriented programming is not a subject to be absorbed in one Sunday afternoon. The author has undertaken to guide the reader through the thickets barring access to this strange but powerful concept. In the first part of the book, he examines the foundations of the subject from many sides and explores it to many depths. Then the author intro- duces MacApp itself through the QuadWorld example. The reader who lacks immediate interest in the details of Macintosh programming can skim these sections and move on to the advanced topics, including an excellent survey of object-oriented languages. The insightful appendix on user interface design is independent of the rest of the book and will be of interest to a wide audience. It has been included here because of its obvious importance to anyone designing a Macintosh application. If you have access to a Macintosh while you are reading this material, you can put your learning to the test and reinforce it with practice. If you have written an application for another machine and want to port it to the Macintosh, this guide can help you in restructuring it for the new user interface. If you have been harboring an exciting idea for an interac- tive application, then after you have mastered the lessons herein, you will be in a better position than ever to try it out. Whatever your plans, let me welcome you to object-oriented programming, and show you to the en- trance that is this book. Larry Tesler Cupertino, California

Reading notes: Opening word 'tosh' appears truncated at the start of the excerpt. Heading 'Foreword' is a section label rather than a clear primary headline.

Printed product names
Macintosh · QuadWorld · MacApp
Languages
English
PDF page 7

About This Book T he Macintosh is more than simply the subject of this book- it is the means by which all of the book's text, figures, and sample programs were created. The thirteen chapters and the two appendices were written and edited with Microsoft Word, each chapter a separate Word document. The original manuscript was prepared on a Macintosh XL and transmitted to the various editors either via the AppleTulk network or on diskette for editing and revision on their Macintoshes. The original keystrokes on my Xl'..s keyboard were "captured" electronically by the typesetter, producing the type you are now reading. Early versions of the manuscript were printed on the Apple ImageWriter and the Apple LaserWriter for review during MacApp's develop- ment stage. The programs in this book were developed either in the Lisa \i\brl<shop (Object Pascal and Clascal) or on the Macintosh itself (Smalltalk, Neon, Object L6go, and Expert::ommonLISP). The eight listings included in the book were either generated in the Lisa \i\brkshop and then "Maccom" ed over to the Macintosh to become Microsoft \i\brd documents, or were text files generated directly on the Macintosh itself and then formatted with Microsoft \i\brd. Nearly all of the more than 200 hundred illustrations in this book were produced on the Macintosh using either MacDraw or MacPaint. These, too, were given to the production editors at Hayden in electronic form. These original MacDraw figures were then edited at Hayden to produce the final figures on these pages. Were it not for the Macintosh's excellent manuscript- and figure- preparation capabilities, this book would have taken considerably longer to prepare. Moreover, a task of this magnitude gave many of these application programs, compilers, and interpreters a real workout, enabling me to discover several bugs that were then communicated to the respective developers. Because of this effort, these may be bugs that you will never see. vi

Reading notes: OCR spacing and character damage in product names such as 'AppleTulk', 'Xl'..s', and 'Workshop' rendered as '\i\brkshop' Possible truncation or misreading of 'Expert::ommonLISP' and 'Lisa \i\brkshop'

Printed product names
Macintosh · Microsoft Word · Macintosh XL · Apple ImageWriter · Apple LaserWriter · MacApp · Object Pascal · Clascal · Smalltalk · Neon · Maccom · MacDraw · MacPaint
Languages
English
PDF page 8

Preface This is a book intended for Macintosh application programmers, not for Macintosh end users. Accordingly, the second-person "you" refers to such a programmer and we reserve the term "user" for the ultimate end users of your software. Tu most effectively profit from reading this book, you should be comfortable at least reading Pascal or C, and have some familiarity with the basic concepts of computer graphics, especially with the QuickDraw graphics library on the Macintosh. A general introduction to programming for Macintosh would also be useful. To this end, Chernicoff's Macintosh Revealed- Unlocking the 1bolbox (Hayden, 1985) provides an excellent introduction to both QuickDraw (in Chapter 5) and Macintosh programming (in Chapters 6 and 7). It is highly recommended as a companion volume to this one, though many of the details explained in Macintosh Revealed are handled for you automatically when you adopt the object-oriented approach to developing Macintosh software. In addition, you should have a user's working knowledge of several application programs on the Macintosh, as many of these are used as examples throughout the book. This book is organized in two major sections. Section I is an introduction to object-oriented programming with all examples taken from Object Pascal, an object-oriented extension of Pascal. Individuals who wish to learn only the basics of this technology will find that this section is self-contained and will enable them to produce sophisticated Pascal applications on the Macintosh. Section II covers the other object-oriented languages on the Macintosh as well as some advanced topics in object-oriented programming. Those who need a more in-depth understanding of object-oriented programming, or who wish to use the object-oriented approach from language:; other than Pascal, will need to read both Section I and II. Of course, the term "Macintosh" refers to the entire Macintosh family of computers, including the Lisa, the predecessor of the first Macintosh. The Lisa is the host of several operating systems and environments. One operating vii

Reading notes: Garbled OCR in 'Chernicoff's Macintosh Revealed- Unlocking the 1bolbox' (likely 'Toolbox') Possible OCR errors such as 'Tu' for 'To' and 'language:;' in the body text

Printed product names
Macintosh · Lisa · QuickDraw · Chernicoff's Macintosh Revealed- Unlocking the 1bolbox · Object Pascal
Printed dates
1985
Languages
English
PDF page 9

viii Preface system, MacWorks, turns the Lisa into a "Macintosh XI.:' -a system that can run almost all Macintosh software, including object-oriented software, without modification. Another operating system runs the "Lisa 7/7 Office System;• a multi-tasking, window environment that also can run programs written in one object-oriented language, Clascal. Yet another environment is the Lisa Workshop, a program development environment that can be used to develop programs in several of the object-oriented languages discussed in this book. There are few details in this book about the Lisa Workshop or the other programming environments in which object-oriented programs are prepared. There are several reasons for this. First, the mechanics of compiling and linking programs and of dealing with various text editors are completely inde- pendent of using an object-oriented language to produce Macintosh applications. Second, some object-oriented languages described here have their own peculiar environments which are supplied with the language's compilers and linkers. Little insight into object-oriented programming would be gained by e]l:amining these. Third, the Macintosh Programmer's Workshop which may become the most popular programming environment, will not be available until several months after this book is published. A couple of formatting conventions are used throughout this book. Code fragments as well as procedure and variable names are set off by a special font like this: FUNCTION TQuadApplication.DoMakeDocument (itsDocKind:INTEGER): TDocument; VAR quadDocument: TQuadDocument; BEGIN NEW (quadDocument); quadDocument.IQuadDocument; DoMakeDocument : = quad Document; END; and information that, while important, is auxiliary or advanced is set c:iff from the rest of the text with a colored background like this:

Reading notes: Some characters in the OCR-like source are damaged (e.g., 'e]l:amining', 'c:iff'), and product names may be imprecise.

Printed product names
Lisa · Macintosh · Lisa 7/7 Office System · Clascal · Lisa Workshop · Macintosh Programmer's Workshop
Languages
English
PDF page 10

Acknowledgments A book like this is never the result of just one person's labor. Many people advised and assisted me during the eighteen months in which this book was written. Larry Tusler of Apple Computer was my main technical contact at Apple. Larry, the leader of the Object Oriented Systems team in the Apple Advanced Development group, read every one of the many drafts of this book, suggested so many improvements that I lost count, and spent countless hours talking with me about object-oriented programming. Without his assistance, this book would probably never have been started or finished. I am also grateful to Larry for allowing me to participate in the a and {3 -test of MacApp and to participate in the MacApp development meetings whenever I was in Cupertino. The entire Object Oriented Systems team at Apple assisted me by reading various drafts and advising me on the implementation of the programs used as examples throughout the book. Among those who went to extraordinary efforts to assist me were Larry Rosenstein, Scott Wallace, Ken Doyle, Dan Ingalls, Barry Haines, Jonathan Simonoff, Harvey Alcabes, and Mark Lentczner. Eileen Mayes assisted me by making sure that I had the latest software and all the necessary technical notes and documentation. Each of these individuals endured numerous phone calls from me and were always willing to discuss the latest changes in MacApp, help me solve a minor crisis, or provide any background I needed. It was indeed a pleasure to have been associated with this group of professionals during the design and implementa- tion of the Tuolkit and MacApp. ix

Reading notes: Garbled characters in 'a and {3 -test' and 'Tuolkit' may be OCR errors Heading 'Acknowledgments' is a section title rather than a primary headline

Printed product names
MacApp
Languages
English
PDF page 11

X Acknowledgments Bryan Lockwood, Sally Breckenridge, and Chet Wisinski, all colleagues of mine at Productivity Products International, read the final manuscript and suggested many changes under the short deadlines that always seem to occur during the final days of finishing a book. Special thanks to Tum Love, President of PPI, for giving me sufficient time to finish this project when there were equally pressing tasks elsewhere. Many other individuals assisted in dealing with the languages their companies market: Guru Jees of Kriya, and Chuck Duft; Mark Achier, and Reese Wcim.er formerly of Kriya (NEON); Denison Bolay of Expertelligence (ExperCommonLISP); Jeremy Jones and Glenn Forrestor of Coral Software (Object Logo); Brad Cox of Productivity Products International (Objective-CJ; and Evelyn van Orden of Xerox Corporation (Smalltalk). Gene Velazques of Flacon Microsystems and John Sauer of The Comm Center were the Apple Authorized Dealers who helped me obtain the sometimes scarce hardware and software for my Lisa and Macintosh. On many occasions these individuals loaned me equipment or found supplies that were just not available anywhere. · Joen Makower of Tilden Press edited the final manuscript, producing consistency and clarity in a draft that lacked both in many places. Bill Grout of Hayden, Martha Steffen of Apple, and literary agent Raphael Sagalyn worked together on the publication details and, in general, brought this book to market. · Finally, my wife Karen was an understanding computer widow during this book's preparation, for which I am forever appreciative. Equally important, she was my most frequent "typical Macintosh user;' upon whose experiences many of my conclusions about the Macintosh user interface were drawn. She also ran the entire manuscript through a spell checker to correct my typing-a task that took many hours just before the Christmas holidays. My heartfelt thanks to all for their assistance, without which this book could not have come to fruition. Any errors or inaccuracies that remain are, of course, mine. - Kurt J. Schmucker Crofton, Maryland

Reading notes: Possible OCR spacing or hyphenation artifacts such as 'Wcim.er', 'Flacon', and 'Velazques' may be misspellings in the source Reading order of the bullet-marked paragraphs is uncertain

Printed product names
Lisa · Macintosh · NEON · ExperCommonLISP · Object Logo · Objective-CJ · Smalltalk
Printed dates
Christmas holidays
Languages
English