Unformatted text preview:

Designing Programs with Class Sam Tobin Hochstadt and David Van Horn January 7 2014 2 This book introduces the fundamental elements of class based program design The book is also available in PDF form here Contents 3 4 CONTENTS Preface 5 CONTENTS 7 This book is a draft textbook to accompany Fundamentals of Computer Science II Honors Introduction to Class Based Program Design at Northeastern University 1 It began its life as a series of course notes from the Spring 2011 incarnation of the class evolved during Spring 2012 and is now being revised throughout the Spring 2013 semester The cid 147 book cid 148 is very much a work in progress which means there are large omis sions and numerous errors Moreover it s certain to change as the course progresses Your patience feedback and bug reports are greatly appreciated The book and its accompanying software are maintained on Github at the following URL https github com dvanhorn dpc 1http www ccs neu edu course cs2510h 8 CONTENTS Design Recipes It puts a lot of emphasis on something called The Design Recipe which sounded hokey to me at cid 2 rst but when I was shown what The Design Recipe was I realized even as someone who s been programming for 35 years that rather than code a solution to something complex in say an hour after 15 20 minutes when I thought I was a third done I was actu ally and suddenly completely done sometimes almost feeling like magic It basically puts a high emphasis on thinking and designing cid 2 rst writing test cases very early picking the right program structure and then cid 2 lling in the blanks and expanding them in a few places Following the Design Recipe not only was I often cid 147 suddenly done cid 148 but because my tests were written before I started coding the meat of a solution I had and continue to have high con cid 2 dence that my program works and will continue to work or alert me quickly to new errors should I make any cid 147 enhancements cid 148 down the road cid 151 Geoffrey S Knauth 2011 The main focus of this book is the design process that leads from problem state ments to well organized solutions oriented around the concept of objects We make extensive use of explicit design guidelines formulated as a number program design recipes as described in How to Design Programs The most general form of the recipe for designing programs is given in cid 2 gure 1 1 Problem Analysis Data De cid 2 nition 2 Contract Purpose Effect Statements Header 3 Examples 4 Template 5 Code 6 Tests Figure 1 The Design Recipe for Programs The objective of the design recipe is to provide a technique that guides programmers cid 151 9 10 CONTENTS novices and professionals alike cid 151 with a systematic approach to problem solving By reasoning systematically programmers can eliminate the incidental complexities of writing software and instead focus their creative energy on what is essentially dif cid 2 cult about a particular problem A great programmer is cid 2 rst a master technician they con tinue to hone and internalize their skills with each day of programming As the chef Jacques P pin said 2 speaking of another cid 2 eld that values the idea of recipes to master the technique you have no choice cid 147 you have to repeat repeat repeat repeat until it becomes part of yourself cid 148 2New York Times cid 147 There s the Wrong Way and Jacques Pepin s Way cid 148 October 18 2011 The Choice of Language and Environment Another lesson we should have learned from the recent past is that the de velopment of cid 147 richer cid 148 or cid 147 more powerful cid 148 programming languages was a mistake in the sense that these baroque monstrosities these conglomer ations of idiosyncrasies are really unmanageable both mechanically and mentally I see a great future for very systematic and very modest pro gramming languages cid 151 Edsger W Dijkstra cid 147 The Humble Programmer cid 148 Turing Award Lecture 1972 In support of this book we have a developed a series of modest programming lan guages that emphasize the principles of object oriented design We use these languages throughout the cid 2 rst part of the book They are deliberately not industrial strength pro gramming languages complete with full featured libraries convenience mechanisms and the usual idiosyncrasies that accompany cid 147 real cid 148 languages Instead we have de signed a progression of simple and consistent languages which embody the common core of modern object oriented languages The idea is that by focusing on the concep tual basis of object oriented programming students can apply their design knowledge regardless of whatever linguistic context they happen to cid 2 nd themselves in down the road In the second part we transition to Java a widely used industrial language that has been developed over more than 15 years The move to Java allows us to explore the application of the principles introduced in the cid 2 rst portion of the course in the context of a practical language As of this draft of the book the course software has been developed and tested with version 5 2 of Racket To install the course software you will cid 2 rst need to install Racket http racket lang org Once installed launch DrRacket the development environment that ships with the Racket system Click on the File Install PLT File and then enter the URL http www ccs neu edu course cs2510h class system latest plt 11 12 CONTENTS After the PLT cid 2 le has been installed select Language Choose Language and se lect the cid 147 Use the language declared in the source cid 148 option You can now write programs in any of the languages included in the course software by writing lang class N as the cid 2 rst line of a cid 2 le where N is a number in 0 1 2 etc To cid 2 nd out more about the languages use Help Desk and search for class 0 to get started The Parts of the Book 13 14 CONTENTS Acknowledgments We are grateful to Matthias Felleisen our TAs Daniel Brown 2011 Asumu Takikawa 2012 and Nicholas Labich 2013 our tutors Alex Lee Nikko Patten Jim Shargo Trevor Sontag 2011 Spencer Florence Sarah Laplante Ryan Plessner 2012 Becca MacKenzie and Kathleen Mullins 2013 and the Northeastern students we have had the privilege of teaching in 2011 and 2012 15 16 CONTENTS Part I Basic Design with Objects 17 Chapter 1 Objects Data Function One of the key concepts behind so called object oriented programming OOP is the notion of an object An object is a new kind of value that can as a cid 2 rst cut be under stood as a


View Full Document

NU CS 2510 - Designing Programs with Class

Documents in this Course
Runner

Runner

5 pages

Load more
Download Designing Programs with Class
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Designing Programs with Class and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Designing Programs with Class and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?