📄 preface.html.svn-base
字号:
some of the grunt programming needed to get such projects off the ground. This usage helpsstudents realize the enormous savings that reuse can bring to a project, and it ofteninduces them to try interface-based design for their own parts of the project. This lattereffect is particularly valuable in team projects, because that's a way of life in the"real world."</p><p>Interfaces and implementations are the focus of Princeton's sophomore-level systemsprogramming course. Assignments require students to be interface clients, implementors,and designers. In one assignment, for example, I distribute Section 8.1's <code>Table</code>interface, the object code for its implementation, and the specifications for Section8.2's word frequency program, <code>wf</code>. The students must implement <code>wf</code>using only my object code for <code>Table</code>. In the next assignment, they get theobject code for <code>wf</code>, and they must implement <code>Table</code>. Sometimes, Ireverse these assignments, but both orders are eye-openers for most students. They areunaccustomed to having only object code for major parts of their program, and theseassignments are usually their first exposure to the semiformal notation used in interfacesand program specification.</p><p>Initial assignments also introduce checked runtime errors and assertions as integralparts of interface specifications. Again, it takes a few assignments before students beginto appreciate the value of these concepts. I forbid "unannounced" crashes; thatis, crashes that are not announced by an assertion failure diagnostic. Programs that crashget a grade of zero. This penalty may seem unduly harsh, but it gets the students'attention. They also gain an appreciation of the advantages of safe languages, like ML andModula-3, in which unannounced crashes are impossible. <small>(This grading policy is lessharsh than it sounds, because in multipart assignments, only the offending part ispenalized, and different assignments have different weights. I've given many zeros, butnone has ever caused a course grade to shift by a whole point.)</small></p><p>Once students have a few interfaces under their belts, later assignments ask them todesign new interfaces and to live with their design choices. For example, one of <aHREF="http://www.cs.princeton.edu/~appel/">Andrew Appel</a>'s favorite assignments is aprimality testing program. Students work in groups to design the interfaces for thearbitrary-precision arithmetic that is needed for this assignment. The results are similarto the interfaces described in Chapters 17 through 19. Different groups design interfaces,and a postassignment comparison of these interfaces, in which the groups critique on oneanothers' work, is always quite revealing. <a HREF="http://www.cs.princeton.edu/~li/">KaiLi</a> accomplishes similar goals with a semester-long project that builds an X-basededitor using the <a HREF="http://www.sunlabs.com/research/tcl/">Tcl/Tk system</a> (J.K.Ousterhout, <cite>Tcl and the Tk Toolkit</cite>, Addison-Wesley, 1994) and editor-specificinterfaces designed and implemented by the students. Tk itself provides another goodexample of interface-based design.</p><p>In advanced courses, I usually package assignments as interfaces and give the studentsfree rein to revise and improve on them, and even to change the goals of the assignment.Giving them a starting point reduces the time required for assignment, and allowingsubstantial changes encourages creative students to explore alternatives. The unsuccessfulalternatives are often more educational than the successful ones. Students invariably godown the wrong road, and they pay for it with greatly increased development time. When, inhindsight, they understand their mistakes, they come to appreciate that designing goodinterfaces is hard, but worth the effort, and they almost always become converts tointerface-based design.</p><h2>How to Get the Software</h2><p>The software in this book has been tested on the following platforms.</p><blockquote> <table CELLPADDING="12"> <tr ALIGN="LEFT" VALIGN="TOP"> <th><i>Processor</i></th> <th><i>Operating Systems</i></th> <th><i>Compilers</i></th> </tr> <tr ALIGN="LEFT" VALIGN="TOP"> <td ALIGN="LEFT">SPARC</td> <td>SunOS 4.1</td> <td>lcc 3.5<br> gcc 2.7.2</td> </tr> <tr ALIGN="LEFT" VALIGN="TOP"> <td>Alpha</td> <td>OSF/1 3.2A</td> <td>lcc 4.0<br> gcc 2.6.3<br> cc</td> </tr> <tr ALIGN="LEFT" VALIGN="TOP"> <td>MIPS R3000</td> <td>IRIX 5.3</td> <td>lcc 3.5<br> gcc 2.6.3<br> cc</td> </tr> <tr ALIGN="LEFT" VALIGN="TOP"> <td>MIPS R3000</td> <td>Ultrix 4.3</td> <td>lcc 3.5<br> gcc 2.5.7</td> </tr> <tr ALIGN="LEFT" VALIGN="TOP"> <td>Pentium</td> <td>Windows 95<br> Windows NT 3.51<br> <small>(except for Threads)</small></td> <td>Microsoft Visual C/C++ 4.0</td> </tr> </table></blockquote><p>A few of the implementations are machine-specific; they assume that the machine hastwo's-complement integer and IEEE floating-point arithmetic, and that unsigned longs canhold object pointers.</p><p>The source code for everything in this book is available for <aHREF="ftp://ftp.cs.princeton.edu/pub/packages/cii">anonymous ftp</a> at <tt>ftp.cs.princeton.edu</tt>in <tt>pub/packages/cii</tt>. Use an <tt>ftp</tt> client to connect to <tt>ftp.cs.princeton.edu</tt>,change to the directory <tt>pub/packages/cii</tt>, and download the file <aHREF="ftp://ftp.cs.princeton.edu/pub/packages/cii/README">README</a>, which describes thecontents of the directory and how to download the distribution.</p><p>The most recent distributions are usually in files named <tt>cii</tt><i>xy</i><tt>.tar.gz</tt>or <tt>cii</tt><i>xy</i><tt>.zip</tt>. <i>xy</i> is the version number, e.g., 10 isversion 1.0. <tt>cii</tt><i>xy</i><tt>.tar.gz</tt> is a U<small>NIX</small> tar filecompressed with <tt>gzip</tt>, and <tt>cii</tt><i>xy</i><tt>.zip</tt> is a ZIP filecompatible with PKZIP version 2.04g. The files in <tt>cii</tt><i>xy</i><tt>.zip</tt> areDOS/Windows text files; that is, their lines end with carriage returns and linefeeds. <tt>cii</tt><i>xy</i><tt>.zip</tt>may also be available on America Online, Compuserve, and other online services.</p><p>Information is also available on the World-Wide Web at URL <aHREF="http://www.cs.princeton.edu/software/cii/">http://www.cs.princeton.edu/software/cii/</a>.This page includes instructions on reporting bugs.</p><h2>Acknowledgments</h2><p>I have been using some of the interfaces in this book for my own research projects andin courses at the University of Arizona and Princeton University since the late 1970s.Students in these courses have been guinea pigs for my drafts of these interfaces. Theirfeedback over the years has been an important contribution to both the code in this bookand its explanation. The Princeton students in several offerings of COS 217 and COS 596deserve special thanks, because they suffered unknowingly through the drafts of most ofwhat's in this book.</p><p>Interfaces are a way of life at Digital's System Research Center (SRC), and my 1992 and1993 summers at SRC working on the Modula-3 project erased any doubts I may have harboredabout the efficacy of this approach. My thanks to SRC for supporting my visits, and toBill Kalsow, Eric Muller, and Greg Nelson for many illuminating discussions.</p><p>My thanks to IDA's Centers for Communications Research in Princeton and La Jolla fortheir support during the summer of 1994 and during my 1995–96 sabbatical. The CCRsprovided ideal hideouts at which to plan and complete this book.</p><p>Technical interactions with colleagues and students have contributed to this book inmany ways. Even seemingly unrelated discussions have provoked improvements in my code andin its explanation. Thanks to Andrew Appel, Greg Astfalk, Jack Davidson, John Ellis, MaryFern醤dez, Chris Fraser, Alex Gounares, Kai Li, Jacob Navia, Maylee Noah, Rob Pike, BillPlauger, John Reppy, Anne Rogers, and Richard Stevens. Careful readings of my code andprose by Rex Jaeschke, Brian Kernighan, Taj Khattra, Richard O'Keefe, Norman Ramsey, andDavid Spuler made a significant contribution to the quality of both.</p><p><a HREF="./">Back to the CII home page</a>.</p><hr><address> <a HREF="http://www.research.microsoft.com/~drh/">David Hanson</a> / <a HREF="mailto:drh@microsoft.com">drh@microsoft.com</a><br> $Revision: 1.13 $ $Date$ </address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -