Rhapsody Developer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Jesse Feiler AP PROFESSIONAL AP Professional is a division of Academic Press Boston San Diego New York London Sydney Tokyo Toronto Find us on the Web! http:/ /www.apnet.com This book is printed on acid-free paper. @ Copyright © 1997 by Academic Press. All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission in writing from the publisher. Excerpts from Chartsmith are copyright © 1997 by Blacksmith, Inc. All rights reserved. Excerpts from OpenBase are copyright © 1997 by OpenBase International, Ltd. All rights reserved. Excerpts from Create are copyright © 1997 by Stone Design, Inc. All rights reserved. Excerpts from OmniWeb are copyright © 1997 by Omni Development, Inc. All rights reserved. Excerpts from TIFFany are copyright © 1997 by Caffeine Software. All rights reserved. All brand names and product names mentioned in this book are trademarks or registered trademarks of their respective companies. Academic Press 525 B Street, Suite 1900, San Diego, CA 92101-4495 1300 Boylston Street, Chestnut Hill, MA 02167 United Kingdom Edition published by ACADEMIC PRESS LIMITED 24-28 Oval Road, London NW1 7DX ISBN 0-12-251334-7 Printed in the United States of America 97 98 99 00 CP 9 8 7 6 5 4 3 2 1 Table of Contents Advanced Mac Look and Feel i Y e llo w Box Mac OS 0P6NSTgP based JaCT^ Core OS: Microkernel, ^0, Fiie System... |Power Macintosh, PowerPC Piatform Hardware Semantics T ables ........................................................................................... xv Preface............................................................................................................ xxi Why Rhapsody?................................................................................ xxii Redefining Ease of U se .............................................................. xxiii Opportunities for Developers ..................................................... xxiv Aboutthe B ook................................................................................ xxv Three Useful Internet A ddresses............................................................ xxv Acknowledgments............................................................................. xxvi Introduction.................................................................................................... I The Search for Better Ways to Write Software...............................................3 v vi • Table o f Contents Improving the Production of C o d e .. .......................... 3 Reusing Code ....... 6 System Softw are..................... ..8 Abstraction ..................................................... 8 The Evolution of Software............... 9 Increasing Complexity of Softw are.. .................. 9 Software for the Twenty-first Century... ................ 9 Summary....................................................... 15 Part I: Introducing Rhapsody 1 . RhapsodyArchitectureOverview ......................................................19 The Evolution of Rhapsody.......... 20 The Beginnings of Operating System s............ 20 Common Interfaces ....... 24 Managing Changes ................. 25 The Object-Oriented/Flat W orld Boundary ..... .................................. 27 Splitting the Operating System .... 29 The Blue Box .... .... .......................... ................................... .... 31 W in d ow s.................... 33 Rhapsody on Mac O S ......................................... ..35 Writing for Rhapsody........ 37 Summary............... 38 2. A Modern OS— The Mach Microkernel ............................................. 39 The Story So Far..... ..... 40 PersonalComputer Operating Systems ............................ ................ 4 1 Sharing ....... 42 Modern Operating Systems ....... 43 Security............................................................... 46 Process Management.............. 47 Memory Management ... 50 Communication Between and Among Processes ....... 50 Failure and Exception Handling .................. 5 I Microkernel Architecture ....... 52 Mach.............. 53 Tasks and Threads ........... 53 Memory Management .............. 54 Table o f Contents • vii Communications Between and Among T asks......................................54 Mach and Other Operating Systems ............................................... .55 Summary.................................................... 56 3. Object-Oriented Programming ........................................................... 57 Object-Oriented Programming................................................................ 58 Why Is It Liked?.............................................................. 59 W here Are the Benefits? .................................... 60 The Learning C u rv e................................................................... 61 Objects ................................................................... 62 Object-Oriented Design Issues................................................................ 64 Inheritance ..............................................................................64 Polymorphism ..........................................................................64 Data Hiding and Encapsulation ...................................................... 65 What It Means— No If Statements ... 66 An Example ........................................................................ 67 Perform ance................................................................. 70 Run-Time Issues................................................................................. 70 Dynamism .............................................................................. 70 Managing Objects in Memory .... 71 Frameworks............................................. 72 Summary.................................................................... 72 4. The Languages of Rhapsody— O b je c tiv e -C .......................................73 Object-Oriented Programming Languages: Two Directions............................... 74 Objects and M essages.................................................................75 The Look ofthe Languages.................... 75 Modern Syntax ........................................................................ 76 Dynamism........................................................................................ 76 Dynamic Typing.................................................... 76 Dynamic Binding....................... 77 Dynamic Linking ....................................................................... 80 Class and Instance Objects..................................................................... 80 Creating New Instances .............................................................. 80 Using Class O b jects................................................................... 81 P rotocols......................................................................................... 82 KeepingltRunning.............................................................................. 83 Syntaxes.............................................................................. 84 Classic Syntax ..................................................................... 84 Modern Syntax ........................................................................ 84 viii • Table o f Contents Summary......................................................................................... 85 5. The Languages of Rhapsody— Java ...................................................... 87 The LookofJava................................................................................ 88 Unicode .................................................................................88 Java Isn’t C ............................................................................. 89 Everything Is an O b ject......................................................................... 90 Object C la ss............................................................................90 Some Java Syntax...................................................................... 92 Inheritance and Organization in Java.......................................................... 93 Packages ................................................................................ 94 Frameworks and Java ................................................................. 94 Exception Handling....................................................................95 Summary......................................................................................... 95 6. The Languages of Rhapsody— C + + ...................................................... 97 The C++ Objective............................................................................. 98 Consequences of Compile-Time Typing.................................................... 100 Small Objects Are Not Expensive.................................................. 100 The Fragile Base Class Problem .................................................... 102 Run-Time Type Identification and Exception Handling.......................... 102 Multiple Inheritance............................................................................ 103 The History of Multiple Inheritance in C++ ...................................... 103 C++ D elegation.......................................................................104 Rhapsody and C++...........................................................................