作者:empty 页数:833 出版社:empty |
Prefaceabstraction, ject-oriented decomposition, functional decomposition, the analysis ofalgorithms, and life-cycle software verification methods, We feel strongly that theseprinciples should be intro due ed to computers e ience students early in their education sothat they lea mn to practice good software techniques from the he ginning.An understanding of theoretical concepts helps students put the new ideas theyencounter into place, and practical advice allows them to apply what they have learned.To teach these concepts to students who may not have completed many college-levelmathemati es courses, we consistently use intuitive explanations, even for to pies thathave a basis in mathematics, like the analysis of algorithms, In all cases, our highestgoal has been to make our explanations as readable and as easily understandable aspossible.
In this book.we assume that students are fam liar with the following C++construe ts:some of the details of these to pies.The third edition incorporates the following changes:
We have included l sidebars within the text to refresh students'memory c once mingject-orientedconstructsmovedforward:Inthelastfiveyears, ject-oriented pro-gramming has become part of the first-year curriculum, as demonstrated by its inclu-sion in all variations of the first year outlined in the Computing Curricula 2001developed by the Joint TaskForce of the IEEE Computer Society and the Association forComputing Machinery.Accordingly, the class concept has moved into the first semes-ter.Because of this, we assume that students have had experience using classes, and wetherefore moved much of the discussion of howto dcf inc and access classes to aside-bar.We have kept a small discussion in the main text.Many students have alr cadyseen inheritance and polymorphism, but the concepts are too important to move to asidebar, so we have moved them from Chapter 6 to Chapter 2.Morcemphasisonject-oricnteddesign:ject-orienteddesignisahardtopieformost students, because people usually think procedurally in their lives.Because of this,we introduce a methodology with four phases:brainstorming, during which the possible
jects in a prlem are isolated; filtering, during which the set of possible jects arereexamined to look for dupli eates and/or missing jects; scenarios, during which handsimulations of the processing take place asking“what if questions and assigningresponsiblities to classes; and responsibility algorithms, during which the algorithms forthe classes are designed.We use CR Ceards to eap ture the results of the four-phaseprocess.The output from the see narios phase is aCRC ear d for each el ass.The CRCear d lists the responsiblities of the class and any other classes with which the el assmust collaborate, hence the name CRC:class, responsibility, collaboration.Morepracticalemphasisontesting:Theconceptofamultipurposetestdriverisintro-duced in Chapter l.After a test plan has been designed, it is implemented as input tothe test driver.Throughout the rest of the book, this technique is used to test the A DTs.The drivers, the input data, and the output data are available on the hook's website:http://computersciencejbpub.com/cppDataStrueturesReduced use of templates:The concept of generic datatypes, as implemented inC++using templates, is very important.Making every ADTa class template after templatesare introduced in Chapter 4, however, inserts an unnecessary complexity into alreadycomplex code.Thus, when introducing a new construct such as a linkedlist or a binarysearch tree, we have chosen to use el asses rather than class templates, Subsequentimplementations of a construct are often in the form of el ass templates, or the student isasked to transforma class into a class template in the exercises.Nonlinkedbinarytreerepresentationcoveredwithbinarytrees:Thenonlinkedrepresen-tation of a binary tree is an important concept within its own right, not just as animplementation for a heap.This implementation, therefore, is covered in Chapter B withother tree implementation techniques.Removal of material on binary expression frees:Although interesting applications oftrees, binary expression trees do not fit into the discussion of abstract datatypes.Thus,we have moved this discussion to the website.InchusionaftheADTset:TheexclusionoftheADTsethasbeenanomissionfrompre-vious editions.Not only is a set an interesting mathematical ject, but there are inter-esting implementation issues.We propose two implementations, one explicit(bitvector} and one implicit[list-based) .Chapter l outlines the basic goals of high-quality software, and the basic principles ofsoftwareeng ince ring for designing and implementing programs to me ct these goals.Abstraction.functional decomposition, and ject-oriented design are discussed.Thischapter also addresses what we see as a critical need in software education:the abilityto design and implement correct programs and to verify that they are actually correct.Topics covered include the concept of“life-e ycle verification; designing for correctnessusing preconditions and post conditions; the use of desk checking and design/code walk-through sand inspections to identify er ors before testing; debugging techniques, datacoverage(black-box) , and code coverage(clear-or white-box) approaches:test plans,Content and Organization
Preface
Verification of Software Correctness 19
Case Study:Fraction Class 50
Summary58
Exercises60
Higher-Level Abstraction and the C++ClassType 85
CaseStudy:Uset-DefinedStringI/OClass100
Summary 116
Exercises 117
TEAM LinG-Live, Informative, Non-cost and Genuine!
Software Engineering Principles
1.1The Software Process 2
1.2Program Design 9
1.3
Data Design and Implementation63
2.1Different Views of Data 64
2.2Abstraction and Built-In Types 72
2.3
2.4Object-Oriented Programming 91
2.5Construe ts for Program Verification 95
A DTs Unsorted List and Sorted List
3.1Lists124
3.2Abstract DataType Unsorted List 125
3.3Abstract DataType Sorted List 146
3.4Comparison of Algorithms 157
A DTs Stack and Queue195
Linked Structures279
Lists Plus333
Comparison of Unsorted and Sorted List ADT Algorithms 164
Overloading Operators167
Object-Oriented Design Methodology 170
CaseStudy:RealEstateListings:AnOhject-OrientedDesign173
Summary188
Exercises189
Stacks 196
MoreaboutGenerics:C++Templates210
Pointer Types 214
Dynamically Allocated Arrays 222
Case Study:Simulation 245
Summary261
Exercises 262
Implementing a Stack as a Linked Structure 280
Implementing a Que ucas a Linked Structure 296
Implementing the Unsorted List as a Linked Structure 307
Implementing the Sorted List as a Linked Structure 318
Summary327
Exercises 327
Circular Linked Lists 334
Doubly Linked Lists 344
Linked Lists with Headers and Trailers 348
Copy Structures 350
TEAM LinG-Live, Informative, Non-cost and Genuine!
A LinkedList as an Array of Records 358
Polymorphism with Virtual Functions 368
A Specialized List ADT 373
Case Study:1m plementing a Large Integer ADT 379
Summary392
Exe reise s 392
The Classic Example of Recursion 401
Using Recursion to Simplify Solutions 411
A Recursive Version of Binary Search 416
Recursive Versions of InsertItem and Delete Item 418
Tracing the Execution of Recursive Function Insert 429
Case Study:O uick Sort 438
Summary446
Ex crc is es447
Recursive Binary Search Trec