معرفی کتاب «Object Oriented Software Construction» نوشتهٔ Bertrand Meyer، منتشرشده توسط نشر Prentice Hall PTR در سال 2000. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Object Oriented Software Construction» در دستهٔ بدون دستهبندی قرار دارد.
OOSC_TAB.PDF -1 Contents 15 PREFAEN3.PDF -1 Preface 3 Structure, reliability, epistemology and classific... 4 Simple but powerful 4 Organization of the text 5 A Book-Wide Web 6 The notation 7 Analysis, design and implementation 8 The environment 8 Acknowledgments (quasi-absence thereof) 9 Foreword to the second edition 10 About the accompanying CD-ROM 11 On the bibliography, Internet sources and exercise... 13 01 - QUALIPS5.PDF 1 1 1 Software quality 27 1.1 EXTERNAL AND INTERNAL FACTORS 27 1.2 A REVIEW OF EXTERNAL FACTORS 28 Correctness 28 Definition: correctness 28 Layers in software development 28 Layers in a development process that includes reus... 29 Robustness 29 Definition: robustness 29 Robustness versus correctness 29 Extendibility 30 Definition: extendibility 30 Reusability 31 Definition: reusability 31 Compatibility 32 Definition: compatibility 32 Efficiency 33 Definition: efficiency 33 Portability 35 Definition: portability 35 Ease of use 35 Definition: ease of use 35 User Interface Design principle 36 Functionality 36 Definition: functionality 36 Osmond’s curves; after [Osmond 1995] 37 Timeliness 38 Definition: timeliness 38 Other qualities 38 About documentation 38 Tradeoffs 39 Key concerns 39 1.3 ABOUT SOFTWARE MAINTENANCE 41 Breakdown of maintenance costs. Source: [Lientz 19... 41 1.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 43 1.5 BIBLIOGRAPHICAL NOTES 43 02 - CRITETOG.PDF 1 2 2 Criteria of object orientation 45 2.1 ON THE CRITERIA 45 How dogmatic do we need to be? 45 Categories 46 2.2 METHOD AND LANGUAGE 46 Seamlessness 46 Classes 47 Assertions 47 Classes as modules 48 Classes as types 48 Feature-based computation 48 Information hiding 49 Exception handling 49 Static typing 49 Genericity 50 Single inheritance 50 Multiple inheritance 50 Repeated inheritance 51 Repeated inheritance 51 Constrained genericity 51 Redefinition 52 Polymorphism 52 Dynamic binding 53 Run-time type interrogation 53 Deferred features and classes 54 Memory management and garbage collection 54 2.3 IMPLEMENTATION AND ENVIRONMENT 55 Automatic update 55 Fast update 55 Persistence 56 Documentation 56 Browsing 57 2.4 LIBRARIES 57 Basic libraries 57 Graphics and user interfaces 57 Library evolution mechanisms 58 Library indexing mechanisms 58 2.5 FOR MORE SNEAK PREVIEW 58 2.6 BIBLIOGRAPHICAL NOTES AND OBJECT RESOURCES 58 03 - MODULMSA.PDF 1 3 3 Modularity 61 3.1 FIVE CRITERIA 62 Modular decomposability 62 Decomposability 62 A top-down hierarchy 63 Modular composability 64 Composability 64 Modular understandability 65 Understan- dability 65 Modular continuity 66 Continuity 67 Modular protection 67 Protection violation 68 3.2 FIVE RULES 68 Direct Mapping 69 Few Interfaces 69 Types of module interconnection structures 69 Small Interfaces 70 Communication bandwidth between modules 70 Explicit Interfaces 72 Data sharing 72 Information Hiding 73 A module under Information Hiding 73 3.3 FIVE PRINCIPLES 75 Linguistic Modular Units 75 Linguistic Modular Units principle 75 Self-Documentation 76 Self-Documentation principle 76 Uniform Access 77 Two representation for a bank account 78 Uniform Access principle 79 The Open-Closed principle 79 Open-Closed principle 79 A module and its clients 80 Old and new clients 80 Adapting a module to new clients 82 Single Choice 83 Single Choice principle 85 3.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 86 3.5 BIBLIOGRAPHICAL NOTES 86 EXERCISES 87 E3.1 Modularity in programming languages 87 E3.2 The Open-Closed principle (for Lisp programme... 87 E3.3 Limits to information hiding 87 E3.4 Metrics for modularity (term project) 87 E3.5 Modularity of existing systems 88 E3.6 Configuration management and inheritance 88 04 - REUSEH5B.PDF 1 4 4 Approaches to reusability 89 4.1 THE GOALS OF REUSABILITY 90 Expected benefits 90 Reuse consumers, reuse producers 91 Reuse Path principle 92 4.2 WHAT SHOULD WE REUSE? 92 Reuse of personnel 92 Reuse of designs and specifications 92 Design patterns 93 Reusability through the source code 94 Reuse of abstracted modules 95 4.3 REPETITION IN SOFTWARE DEVELOPMENT 96 4.4 NON-TECHNICAL OBSTACLES 96 The NIH syndrome 97 The economics of procurement 98 Software companies and their strategies 98 Accessing components 99 A note about component indexing 100 Formats for reusable component distribution 101 An assessment 103 4.5 THE TECHNICAL PROBLEM 103 Change and constancy 103 The reuse-redo dilemma 104 4.6 FIVE REQUIREMENTS ON MODULE STRUCTURES 105 Type Variation 106 Routine Grouping 106 Implementation Variation 106 Representation Independence 106 Factoring Out Common Behaviors 107 Some possible table implementations 108 Sequential structure with cursor 109 Array representation of sequential table with cur... 109 Linked list representation of sequential table wit... 110 Sequential file representation of a sequential tab... 110 4.7 TRADITIONAL MODULAR STRUCTURES 111 Routines 111 Packages 112 Packages: an assessment 114 4.8 OVERLOADING AND GENERICITY 115 Syntactic overloading 115 Role of overloading 116 Semantic overloading (a preview) 117 Genericity 118 Role of genericity 119 Basic modularity techniques: an assessment 119 4.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 120 4.10 BIBLIOGRAPHICAL NOTES 121 05 - TOWAR8VR.PDF 1 5 5 Towards object technology 123 5.1 THE INGREDIENTS OF COMPUTATION 123 The basic triangle 123 The three forces of computation 123 5.2 FUNCTIONAL DECOMPOSITION 125 Continuity 125 Top-down development 126 Top-down design: tree structure 127 Not just one function 127 Structure of a simple payroll program 128 Finding the top 129 Real systems have no top. 130 Functions and evolution 130 Interfaces and software design 131 Premature ordering 132 Ordering and O-O development 133 Reusability 134 The context of a module in top-down design 135 Production and description 136 Top-down design: an assessment 136 5.3 OBJECT-BASED DECOMPOSITION 136 Extendibility 137 Reusability 137 Compatibility 137 5.4 OBJECT-ORIENTED SOFTWARE CONSTRUCTION 138 Object-oriented software construction (definition ... 138 OBJECT MOTTO 138 5.5 ISSUES 139 Finding the object types 139 Describing types and objects 140 Describing the relations and structuring software 140 5.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 141 5.7 BIBLIOGRAPHICAL NOTES 141 06 - ADTO9G.PDF 1 6 6 Abstract data types 143 6.1 CRITERIA 144 6.2 IMPLEMENTATION VARIATIONS 144 Stack representations 145 Three possible representations for a stack 145 Head-to-head representation for two stacks 146 The danger of overspecification 147 How long is a middle initial? 147 6.3 TOWARDS AN ABSTRACT VIEW OF OBJECTS 148 Using the operations 148 A laissez-faire policy for the society of modules 149 Name consistency 149 How not to handle abstractions 150 6.4 FORMALIZING THE SPECIFICATION 151 Specifying types 152 Genericity 153 Listing the functions 154 Applying the put function 155 Function categories 156 The AXIOMS paragraph 157 Applying the put function 158 Two or three things we know about stacks 159 Partial functions 160 Preconditions 160 The complete specification 161 ADT specification of stacks 161 Nothing but the truth 162 Stack manipulations 163 6.5 FROM ABSTRACT DATA TYPES TO CLASSES 164 Classes 164 Definition: class 164 Definition: deferred, effective class 164 How to produce an effective class 165 The role of deferred classes 165 Abstract data types and information hiding 166 The ADT view of a module under information hiding 166 Introducing a more imperative view 167 Back to square one? 168 Object-oriented software construction 169 Object-oriented software construction (definition ... 169 6.6 BEYOND SOFTWARE 169 6.7 SUPPLEMENTARY TOPICS 170 More on implicitness 171 Specification versus design 172 Definition: transition from analysis (specificatio... 172 Classes versus records 172 Alternatives to partial functions 173 Is my specification complete? 175 Definition: correct ADT expression 176 Definition: sufficient completeness 177 Definition: ADT consistency 177 Proving sufficient completeness 178 Weight Consistency rule 178 Definition: weight 179 Zero Weight rule 179 STACK AXIOMS 179 Canonical Reduction rule 180 6.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 181 6.9 BIBLIOGRAPHICAL NOTES 182 EXERCISES 183 E6.1 Points 183 E6.2 Boxers 183 E6.3 Bank accounts 183 E6.4 Messages 183 E6.5 Names 183 E6.6 Text 183 E6.7 Buying a house 184 E6.8 More stack operations 184 E6.9 Bounded stacks 184 E6.10 Queues 184 E6.11 Dispensers 184 E6.12 Booleans 184 E6.13 Sufficient completeness 184 E6.14 Consistency 184 07 - CLASSUU1.PDF 1 7 7 The static structure: classes 185 7.1 OBJECTS ARE NOT THE SUBJECT 185 Definition: class 185 7.2 AVOIDING THE STANDARD CONFUSION 186 What would you think of this? 186 The mold and the instance 187 Metaclasses 188 7.3 THE ROLE OF CLASSES 189 Modules and types 190 The class as module and type 190 7.4 A UNIFORM TYPE SYSTEM 191 Object rule 191 7.5 A SIMPLE CLASS 192 The features 192 A point and its coordinates 192 Attributes and routines 193 Representing a point in cartesian coordinates 193 Representing a point in polar coordinates 193 Feature classification, by role 194 Uniform access 195 Feature classification, by implementation 195 The class 196 7.6 BASIC CONVENTIONS 197 Recognizing feature kinds 197 Routine bodies and header comments 198 The indexing clause 198 Denoting a function’s result 199 Style rules 200 Inheriting general-purpose facilities 200 7.7 THE OBJECT-ORIENTED STYLE OF COMPUTATION 201 The current instance 201 Clients and suppliers 202 Definition: client, supplier 202 The origin 203 Feature call 203 Effect of calling a feature f on a target x 204 The Single Target principle 204 Single Target principle 204 The module-type identification 205 How the module-type merge works 205 The role of Current 205 Feature Call principle 206 Qualified and unqualified calls 206 Operator features 207 7.8 SELECTIVE EXPORTS AND INFORMATION HIDING 211 Full disclosure 211 Restricting client access 211 Style for declaring secret features 212 Exporting to yourself 213 7.9 PUTTING EVERYTHING TOGETHER 214 General relativity 214 The Big Bang 214 Definition: system execution 215 Systems 216 Definition: system closure 216 Not a main program 217 Assembling a system 218 A directory structure 219 Printing your name 220 Structure and order: the software developer as ars... 221 7.10 DISCUSSION 223 Form of declarations 223 Attributes vs. functions 224 Exporting attributes 225 The client’s privileges on an attribute 226 Possible client privileges on an attribute 227 Optimizing calls 228 The architectural role of selective exports 229 Listing imports 230 Denoting the result of a function 230 Complement: a precise definition of entities 233 Definition: entity 233 7.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 233 7.12 BIBLIOGRAPHICAL NOTES 235 EXERCISES 236 E7.1 Clarifying the terminology 236 E7.2 POINT as an abstract data type 236 E7.3 Completing POINT 236 E7.4 Polar coordinates 236 08 - OBJECO8I.PDF 1 8 8 The run-time structure: objects 237 8.1 OBJECTS 238 What is an object? 238 Definition: object 238 Basic form 239 Simple fields 240 A simple notion of book 241 An object representing a book 241 Writers 242 A “writer” object 242 References 242 Two “book” objects with “writer” subobjects 243 Two “book” objects with references to the same “wr... 244 Definition: reference 244 An object with a void reference field 244 Object identity 245 Declaring references 246 Self-reference 246 Direct and indirect self- reference 246 A look at the run-time object structure 247 A possible run- time object structure 247 8.2 OBJECTS AS A MODELING TOOL 248 The four worlds of software development 249 Molds and their instances 249 Reality: a cousin twice removed 250 8.3 MANIPULATING OBJECTS AND REFERENCES 251 Dynamic creation and reattachment 251 The creation instruction 252 Effect of a basic creation instruction 253 Default initialization values 253 A newly created and initialized object 254 The global picture 254 Why explicit creation? 255 8.4 CREATION PROCEDURES 256 Overriding the default initializations 256 Effect of a creation call 257 The export status of creation procedures 258 Rules on creation procedures 258 Multiple creation and overloading 259 8.5 MORE ON REFERENCES 260 States of a reference 260 The possible states of a reference 260 Void references and calls 260 8.6 OPERATIONS ON REFERENCES 262 Attaching a reference to an object 262 Before reference assignment 263 After reference assignment 263 Reference comparison 264 The void value 264 Object cloning and equality 265 De-attaching a reference from an object 265 Cloning an object 266 Object copying 267 Deep clone and comparison 267 Deep storage: a first view of persistence 270 Definition: direct dependents, dependents 270 Three mutually dependent objects 271 “Book” and “Writer” objects 271 Persistence Closure principle 272 8.7 COMPOSITE OBJECTS AND EXPANDED TYPES 274 References are not sufficient 274 Expanded types 274 A composite object with one subobject 275 Definition: expanded type 275 The role of expanded types 276 “Knows about” and “contains” relations between obj... 277 Aggregation 278 Properties of expanded types 278 Expanded Client rule 279 No references to subobjects 280 A subobject with a reference to another object 280 A reference to a subobject 281 8.8 ATTACHMENT: REFERENCE AND VALUE SEMANTICS 281 Attachment 281 Definition: attachment 282 Reference and copy attachment 282 Hybrid attachments 283 Effect of attachment x := y 284 Equality comparison 284 Meaning of comparison x = y 285 8.9 DEALING WITH REFERENCES: BENEFITS AND DANGERS 285 Dynamic aliasing 285 Sharing as a result of an attachment 286 The semantics of aliasing 286 Coming to terms with dynamic aliasing 287 Aliasing in software and elsewhere 288 A linked circular list 288 Encapsulating reference manipulations 289 8.10 DISCUSSION 290 Graphical conventions 291 References and simple values 292 Simula-style notations for operations on reference... 292 The form of clone and equality operations 294 The status of universal operations 296 8.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 296 8.12 BIBLIOGRAPHICAL NOTES 297 EXERCISES 297 E8.1 Books and authors 297 E8.2 Persons 297 E8.3 Notation design 298 09 - MEMORGMP.PDF 1 9 9 Memory management 299 9.1 WHAT HAPPENS TO OBJECTS 299 Object creation 299 Three modes of object management 300 The static mode 300 The stack- based mode 301 The free (heap- based) mode 301 Using the free mode 302 Space reclamation in the three modes 302 Allocation and deallocation in a block- structured... 303 Detachment 303 Detachment 303 Unreachable objects 304 Detachment is not always death 304 Reachable objects in classical approaches 305 Live objects (in color) and dead objects (in black... 306 Entity allocation for a procedure 307 Reachable objects in the object-oriented model 308 Reachability in the object- oriented model 308 Objects attached to local entities 309 The memory management problem in the object-orient... 310 Definition: origins, reachable and unreachable obj... 310 The three answers 310 9.2 THE CASUAL APPROACH 311 Can the casual approach be justified? 311 Do we care about memory any more? 311 A byte here, a byte there, and soon we will be tal... 312 9.3 RECLAIMING MEMORY: THE ISSUES 313 9.4 PROGRAMMER-CONTROLLED DEALLOCATION 314 The reliability issue 314 The ease of development issue 315 Direct and indirect self- reference 316 9.5 THE COMPONENT-LEVEL APPROACH 317 Managing space for a linked list 317 Dealing with recycled objects 319 Discussion 320 9.6 AUTOMATIC MEMORY MANAGEMENT 321 The need for automatic techniques 321 What exactly is reclamation? 322 9.7 REFERENCE COUNTING 322 Uncollectible cyclic structure 323 9.8 GARBAGE COLLECTION 324 The garbage collection mechanism 324 Garbage collector requirements 325 Garbage collector properties 325 Garbage collection basis 326 All-or-nothing collection 326 Advanced approaches to garbage collection 328 Parallel garbage collection algorithms 328 9.9 PRACTICAL ISSUES OF GARBAGE COLLECTION 329 Class MEMORY 329 A disposal mechanism 330 Garbage collection and external calls 331 9.10 AN ENVIRONMENT WITH MEMORY MANAGEMENT 332 Basics 332 Challenges 332 Object movement 333 Garbage collection mechanism 333 Bulimia and anorexia 334 Garbage collector operation 334 9.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 335 9.12 BIBLIOGRAPHICAL NOTES 335 EXERCISES 336 E9.1 Patterns of object creation 336 E9.2 What level of reclamation? 336 E9.3 Sharing the stack of available elements 336 E9.4 Sharing more 336 10 - GENERDE8.PDF 1 10 10 Genericity 337 Dimensions of generalization 337 10.1 HORIZONTAL AND VERTICAL TYPE GENERALIZATION 337 10.2 THE NEED FOR TYPE PARAMETERIZATION 338 Generic abstract data types 338 The issue 339 The role of typing 339 10.3 GENERIC CLASSES 340 Declaring a generic class 341 Using a generic class 342 Terminology 342 Type checking 343 The type rule 343 Operations on entities of generic types 344 Uses of entities of a formal generic type 344 Types and classes 345 10.4 ARRAYS 345 Arrays as objects 345 Array properties 346 Efficiency considerations 347 An infix synonym 348 10.5 THE COST OF GENERICITY 348 10.6 DISCUSSION: NOT DONE YET 349 10.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 350 10.8 BIBLIOGRAPHICAL NOTES 350 EXERCISES 350 E10.1 Constrained genericity 350 E10.2 Two-dimensional arrays 351 E10.3 Using your own formal generic parameter as s... 351 11 - CONTRE22.PDF 1 11 11 Design by Contract: building reliable softwa... 353 11.1 BASIC RELIABILITY MECHANISMS 354 11.2 ABOUT SOFTWARE CORRECTNESS 355 Software Correctness property 355 11.3 EXPRESSING A SPECIFICATION 356 Correctness formulae 356 Meaning of a correctness formula {P} A {Q} 357 Weak and strong conditions 357 Sinecure 1 358 Sinecure 2 358 11.4 INTRODUCING ASSERTIONS INTO SOFTWARE TEXTS 359 11.5 PRECONDITIONS AND POSTCONDITIONS 360 A stack class 360 Preconditions 362 Postconditions 362 A pedagogical note 362 11.6 CONTRACTING FOR SOFTWARE RELIABILITY 363 Rights and obligations 363 A routine contract: routine put for a stack class 364 Zen and the art of software reliability: guarantee... 364 Non-Redundancy principle 365 Assertions are not an input checking mechanism 367 Using filter modules 368 Assertions are not control structures 368 Assertion Violation rule (1) 368 Assertion violation rule (2) 369 Errors, defects and other creeping creatures 369 Terms to denote software woes 369 11.7 WORKING WITH ASSERTIONS 370 A stack class 370 Stack implemented with an array (see page 123 for ... 370 The imperative and the applicative 373 The imperative- applicative opposition 375 A note on empty structures 375 Precondition design: tolerant or demanding? 376 Reasonable Precondition principle 378 Preconditions and export status 379 Precondition Availability rule 380 A tolerant module 381 11.8 CLASS INVARIANTS 385 Definition and example 385 Form and properties of class invariants 386 The life of an object 387 An invariant that varies 388 Who must preserve the invariant? 388 Invariant rule 388 The role of class invariants in software engineeri... 389 Invariants and contracting 390 11.9 WHEN IS A CLASS CORRECT? 391 The correctness of a class 391 Definition: class correctness 392 The life of an object 392 (This figure first appeared on page 366.) 392 The role of creation procedures 393 Arrays revisited 394 11.10 THE ADT CONNECTION 395 Not just a collection of functions 395 Class features vs. ADT functions 396 Expressing the axioms 396 The abstraction function 397 Transformations 397 on abstract and concrete objects 397 Class-ADT Consistency property 397 Implementation invariants 398 Same abstract object, two representations 399 11.11 AN ASSERTION INSTRUCTION 400 11.12 LOOP INVARIANTS AND VARIANTS 402 Loop trouble 402 Four (wrong) attempts at binary search. 403 From [M 1990] 403 Getting loops right 404 Approximating an array by successive slices 405 Ingredients for a provably correct loop 405 A loop computation (from [M 1990]) 406 Loop syntax 408 11.13 USING ASSERTIONS 411 Assertions as a tool for writing correct software 411 Using assertions for documentation: the short form... 411 Monitoring assertions at run time 414 How much assertion monitoring? 416 11.14 DISCUSSION 420 Why run-time monitoring? 420 The expressive power of assertions 421 Including functions in assertions 422 Assertion Evaluation rule 425 Class invariants and reference semantics 425 Consistency of forward and backward references 426 Violating the invariant 427 More to come 428 11.15 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 428 11.16 BIBLIOGRAPHICAL NOTES 429 EXERCISES 430 E11.1 Complex numbers 430 E11.2 A class and its ADT 430 E11.3 Complete assertions for stacks 431 E11.4 Exporting the size 431 E11.5 An implementation invariant 431 E11.6 Assertions and exports 431 E11.7 Finding the bugs 431 E11.8 Invariant violations 431 E11.9 Random number generators 431 E11.10 A queue module 432 E11.11 A set module 432 POSTSCRIPT: THE ARIANE 5 CRASH 432 12 - EXCEP1NG.PDF 1 12 12 When the contract is broken: exception handl... 433 12.1 BASIC CONCEPTS OF EXCEPTION HANDLING 433 Failures 433 Definitions: success, failure 434 Exceptions 434 Definition: exception 434 Sources of exceptions 434 Definition: exception cases 435 Failures and exceptions 435 Causes of failure 435 Definition: failure cases 436 12.2 HANDLING EXCEPTIONS 436 How not to do it — a C-Unix example 436 How not to do it — an Ada example 437 Ada Exception rule 438 Exception handling principles 439 Disciplined Exception Handling principle 439 The call chain 440 The call chain 440 12.3 AN EXCEPTION MECHANISM 441 Rescue and Retry 441 How to fail without really trying 442 Failure principle 442 An exception history table 442 An exception history table 443 12.4 EXCEPTION HANDLING EXAMPLES 444 A failed execution 444 Fragile input 444 Recovering from hardware or operating system excep... 445 Retrying for software fault tolerance 446 N-version programming 448 12.5 THE TASK OF A RESCUE CLAUSE 449 The correctness of a rescue clause 449 The life of an object 450 Correctness rule for failure-inducing rescue claus... 451 Correctness rule for retry-inducing rescue clauses... 451 A clear separation of roles 451 When there is no rescue clause 452 12.6 ADVANCED EXCEPTION HANDLING 453 Exception queries 453 How fine a degree of control? 456 Exception Simplicity principle 456 Developer exceptions 456 12.7 DISCUSSION 457 Disciplined exceptions 458 Should exceptions be objects? 458 The methodological perspective 459 12.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 459 12.9 BIBLIOGRAPHICAL NOTES 460 EXERCISES 460 E12.1 Largest integer 460 E12.2 Exception objects 460 13 - MECHADU5.PDF 1 13 13 Supporting mechanisms 461 13.1 INTERFACING WITH NON-O-O SOFTWARE 461 External routines 461 Advanced variants 462 Uses of external routines 463 Object-oriented re-architecturing 463 The compatibility issue: hybrid software or hybrid... 465 13.2 ARGUMENT PASSING 466 Permissible operations on a reference argument 467 13.3 INSTRUCTIONS 469 Procedure call 469 Qualified Call rule 469 Assignment 470 Creation instruction 470 Conditional 470 Multi-branch 471 Loop 473 Check 474 Debug 474 Retry 474 13.4 EXPRESSIONS 474 Manifest constants 474 Function calls 475 Current object 475 Expressions with operators 475 Non-strict boolean operators 476 Non-strict boolean operators 476 13.5 STRINGS 478 13.6 INPUT AND OUTPUT 479 13.7 LEXICAL CONVENTIONS 479 13.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 480 EXERCISES 480 E13.1 External classes 480 E13.2 Avoiding non-strict operators 480 14 - INHVJG.PDF 1 14 14 Introduction to inheritance 483 14.1 POLYGONS AND RECTANGLES 484 Polygons 484 Rectangles 486 Basic conventions and terminology 488 Inheritance terminology 488 An inheritance link 488 Invariant inheritance 489 Invariant inheritance rule 489 Inheritance and creation 489 Creation Inheritance rule 490 An example hierarchy 491 14.2 POLYMORPHISM 491 Polymorphic attachment 491 Figure type hierarchy 492 What exactly happens during a polymorphic attachme... 493 Polymorphic reference reattachment 493 Polymorphic data structures 494 A polymorphic array 495 Dimensions of generalization 495 14.3 TYPING FOR INHERITANCE 496 Type consistency 496 Feature Call rule 497 Limits to polymorphism 498 Definition: conformance 498 Type Conformance rule 498 Instances 499 Definition: direct instance, instance 499 Static-dynamic type consistency 499 Static type, dynamic type 499 Are the restrictions justified? 500 Can ignorance be bliss? 501 After a polymorphic 501 attachment 501 When you want to force a type 502 Polymorphic creation 503 14.4 DYNAMIC BINDING 504 Using the right variant 504 Redefinition and assertions 505 On the implementation of dynamic binding 506 14.5 DEFERRED FEATURES AND CLASSES 506 Moving arbitrary figures 506 The FIGURE hierarchy again 507 Deferring a feature 508 Effecting a feature 508 Definition: redeclaration 509 Deferred classes 510 Definition: deferred, effective class 510 Deferred class declaration rule 510 Graphical conventions 511 What to do with deferred classes 511 Deferred Class No-Instantiation rule 511 Specifying the semantics of deferred features and ... 512 List with cursor 512 Cursor positions 514 14.6 REDECLARATION TECHNIQUES 515 Redeclaring a function into an attribute 515 Not the other way around 516 Using the original version in a redefinition 517 14.7 THE MEANING OF INHERITANCE 518 The dual perspective 518 Inheritance mechanisms and their role 519 The module view 519 Draft structure for a table library 521 The type view 521 Inheritance and decentralization 522 Representation independence 524 The extension-specialization paradox 524 14.8 THE ROLE OF DEFERRED CLASSES 525 Back to abstract data types 525 Deferred classes as partial implementations: the n... 528 Variants of the notion of table 528 Don’t call us, we’ll call you 529 Programs with holes 530 Deferred classes for analysis and global design 531 14.9 DISCUSSION 532 Explicit redefinition 532 Accessing the precursor of a routine 532 Dynamic binding and efficiency 532 Estimating the overhead 534 Static binding as an optimization 535 A button by any other name: when static binding is... 536 Dynamic Binding principle 536 A parent version may fail to satisfy the new invar... 538 The C++ approach to binding 538 14.10 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 541 14.11 BIBLIOGRAPHICAL NOTES 542 EXERCISES 542 E14.1 Polygons and rectangles 542 E14.2 How few vertices for a polygon? 542 E14.3 Geometrical objects with two coordinates 543 E14.4 Inheritance without classes 543 E14.5 Non-creatable classes 543 E14.6 Deferred classes and rapid prototyping 543 E14.7 Table searching library (term project) 543 E14.8 Kinds of deferred feature 543 E14.9 Complex numbers 544 15 - INH_MFJE.PDF 1 15 15 Multiple inheritance 545 15.1 EXAMPLES OF MULTIPLE INHERITANCE 545 What not to use as an introductory example 546 A case of multiple inheritanceº 546 º that is a case of repeated inheritance 546 Can an airplane be an asset? 547 Company planes 547 Numeric and comparable values 548 Windows are trees and rectangles 550 Multiple structure inheritance 550 Windows and subwindows 550 Trees are lists and list elements 551 A tree of integers 552 Definition: tree 552 Composite figures 553 Elementary figures 553 A composite figure 553 A composite figure is a figure and a list of figur... 554 The marriage of convenience 556 A marriage of convenience 556 Structure inheritance 558 Facility inheritance 558 Buttonholes 559 Pick-and- throw 560 An assessment 560 15.2 FEATURE RENAMING 561 Name clashes 561 Effects of renaming 563 A name clash, removed 563 Renaming and redeclaration 564 Local name adaptation 564 The game of the name 565 Using a parent’s creation procedure 565 15.3 FLATTENING THE STRUCTURE 567 The flat form 567 Displaying a flat form 568 Uses of the flat form 568 The flat-short form 569 15.4 REPEATED INHERITANCE 569 Sharing ancestors 569 Repeated inheritance 569 Intercontinental drivers 570 Sharing and replication 570 Kinds of driver 571 Repeated Inheritance rule 572 Sharing and replication 573 Attribute replication 573 Unobtrusive repeated inheritance 574 Redundant inheritance 574 The renaming rule 575 Definition: final name 575 Single Name rule 575 Conflicting redefinitions 577 Redefinition causing potential ambiguity 577 Conflicts under sharing: undefinition and join 577 Two parents with features to be merged 578 Conflicts under replication: selection 579 The need for selection 579 Select rule 581 Selecting everything 581 Keeping the original version of a redefined featur... 581 An advanced example 583 Window variants 584 Repeated inheritance and genericity 587 Genericity in Repeated Inheritance rule 588 Rules on names 588 Name clashes: definition and rule 588 15.5 DISCUSSION 589 Renaming 589 O-O development and overloading 590 15.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 592 15.7 BIBLIOGRAPHICAL NOTES 593 EXERCISES 593 E15.1 Windows as trees 593 E15.2 Is a window a string? 593 E15.3 Doing windows fully 593 E15.4 Figure iterators 593 E15.5 Linked stacks 593 E15.6 Circular lists and chains 593 E15.7 Trees 594 E15.8 Walking menus 594 Walking menus 594 E15.9 The flat precursor 594 E15.10 Repeated inheritance for replication 594 16 - INH_MF75.PDF 1 16 16 Inheritance techniques 595 16.1 INHERITANCE AND ASSERTIONS 595 Invariants 596 Parents’ Invariant rule 596 Preconditions and postconditions in the presence o... 596 The routine, the client and the contract 596 The routine, the client, the contract and the desc... 597 How to cheat clients 598 How to be honest 599 Assertion Redeclaration rule (1) 599 An example 599 Cutting out the middleman 601 The routine, the client and the sub- contractor 601 Subcontracting 602 Abstract preconditions 602 The language rule 604 Assertion Redeclaration rule (2) 604 Redeclaring into attributes 605 A mathematical note 606 16.2 THE GLOBAL INHERITANCE STRUCTURE 606 Universal classes 606 Universal Class rule 606 The global inheritance struct OOSC_TAB.PDF -1 Contents 15 PREFAEN3.PDF -1 Preface 3 Structure, reliability, epistemology and classific... 4 Simple but powerful 4 Organization of the text 5 A Book-Wide Web 6 The notation 7 Analysis, design and implementation 8 The environment 8 Acknowledgments (quasi-absence thereof) 9 Foreword to the second edition 10 About the accompanying CD-ROM 11 On the bibliography, Internet sources and exercise... 13 01 - QUALIPS5.PDF 1 1 1 Software quality 27 1.1 EXTERNAL AND INTERNAL FACTORS 27 1.2 A REVIEW OF EXTERNAL FACTORS 28 Correctness 28 Definition: correctness 28 Layers in software development 28 Layers in a development process that includes reus... 29 Robustness 29 Definition: robustness 29 Robustness versus correctness 29 Extendibility 30 Definition: extendibility 30 Reusability 31 Definition: reusability 31 Compatibility 32 Definition: compatibility 32 Efficiency 33 Definition: efficiency 33 Portability 35 Definition: portability 35 Ease of use 35 Definition: ease of use 35 User Interface Design principle 36 Functionality 36 Definition: functionality 36 Osmond’s curves; after [Osmond 1995] 37 Timeliness 38 Definition: timeliness 38 Other qualities 38 About documentation 38 Tradeoffs 39 Key concerns 39 1.3 ABOUT SOFTWARE MAINTENANCE 41 Breakdown of maintenance costs. Source: [Lientz 19... 41 1.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 43 1.5 BIBLIOGRAPHICAL NOTES 43 02 - CRITETOG.PDF 1 2 2 Criteria of object orientation 45 2.1 ON THE CRITERIA 45 How dogmatic do we need to be? 45 Categories 46 2.2 METHOD AND LANGUAGE 46 Seamlessness 46 Classes 47 Assertions 47 Classes as modules 48 Classes as types 48 Feature-based computation 48 Information hiding 49 Exception handling 49 Static typing 49 Genericity 50 Single inheritance 50 Multiple inheritance 50 Repeated inheritance 51 Repeated inheritance 51 Constrained genericity 51 Redefinition 52 Polymorphism 52 Dynamic binding 53 Run-time type interrogation 53 Deferred features and classes 54 Memory management and garbage collection 54 2.3 IMPLEMENTATION AND ENVIRONMENT 55 Automatic update 55 Fast update 55 Persistence 56 Documentation 56 Browsing 57 2.4 LIBRARIES 57 Basic libraries 57 Graphics and user interfaces 57 Library evolution mechanisms 58 Library indexing mechanisms 58 2.5 FOR MORE SNEAK PREVIEW 58 2.6 BIBLIOGRAPHICAL NOTES AND OBJECT RESOURCES 58 03 - MODULMSA.PDF 1 3 3 Modularity 61 3.1 FIVE CRITERIA 62 Modular decomposability 62 Decomposability 62 A top-down hierarchy 63 Modular composability 64 Composability 64 Modular understandability 65 Understan- dability 65 Modular continuity 66 Continuity 67 Modular protection 67 Protection violation 68 3.2 FIVE RULES 68 Direct Mapping 69 Few Interfaces 69 Types of module interconnection structures 69 Small Interfaces 70 Communication bandwidth between modules 70 Explicit Interfaces 72 Data sharing 72 Information Hiding 73 A module under Information Hiding 73 3.3 FIVE PRINCIPLES 75 Linguistic Modular Units 75 Linguistic Modular Units principle 75 Self-Documentation 76 Self-Documentation principle 76 Uniform Access 77 Two representation for a bank account 78 Uniform Access principle 79 The Open-Closed principle 79 Open-Closed principle 79 A module and its clients 80 Old and new clients 80 Adapting a module to new clients 82 Single Choice 83 Single Choice principle 85 3.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 86 3.5 BIBLIOGRAPHICAL NOTES 86 EXERCISES 87 E3.1 Modularity in programming languages 87 E3.2 The Open-Closed principle (for Lisp programme... 87 E3.3 Limits to information hiding 87 E3.4 Metrics for modularity (term project) 87 E3.5 Modularity of existing systems 88 E3.6 Configuration management and inheritance 88 04 - REUSEH5B.PDF 1 4 4 Approaches to reusability 89 4.1 THE GOALS OF REUSABILITY 90 Expected benefits 90 Reuse consumers, reuse producers 91 Reuse Path principle 92 4.2 WHAT SHOULD WE REUSE? 92 Reuse of personnel 92 Reuse of designs and specifications 92 Design patterns 93 Reusability through the source code 94 Reuse of abstracted modules 95 4.3 REPETITION IN SOFTWARE DEVELOPMENT 96 4.4 NON-TECHNICAL OBSTACLES 96 The NIH syndrome 97 The economics of procurement 98 Software companies and their strategies 98 Accessing components 99 A note about component indexing 100 Formats for reusable component distribution 101 An assessment 103 4.5 THE TECHNICAL PROBLEM 103 Change and constancy 103 The reuse-redo dilemma 104 4.6 FIVE REQUIREMENTS ON MODULE STRUCTURES 105 Type Variation 106 Routine Grouping 106 Implementation Variation 106 Representation Independence 106 Factoring Out Common Behaviors 107 Some possible table implementations 108 Sequential structure with cursor 109 Array representation of sequential table with cur... 109 Linked list representation of sequential table wit... 110 Sequential file representation of a sequential tab... 110 4.7 TRADITIONAL MODULAR STRUCTURES 111 Routines 111 Packages 112 Packages: an assessment 114 4.8 OVERLOADING AND GENERICITY 115 Syntactic overloading 115 Role of overloading 116 Semantic overloading (a preview) 117 Genericity 118 Role of genericity 119 Basic modularity techniques: an assessment 119 4.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 120 4.10 BIBLIOGRAPHICAL NOTES 121 05 - TOWAR8VR.PDF 1 5 5 Towards object technology 123 5.1 THE INGREDIENTS OF COMPUTATION 123 The basic triangle 123 The three forces of computation 123 5.2 FUNCTIONAL DECOMPOSITION 125 Continuity 125 Top-down development 126 Top-down design: tree structure 127 Not just one function 127 Structure of a simple payroll program 128 Finding the top 129 Real systems have no top. 130 Functions and evolution 130 Interfaces and software design 131 Premature ordering 132 Ordering and O-O development 133 Reusability 134 The context of a module in top-down design 135 Production and description 136 Top-down design: an assessment 136 5.3 OBJECT-BASED DECOMPOSITION 136 Extendibility 137 Reusability 137 Compatibility 137 5.4 OBJECT-ORIENTED SOFTWARE CONSTRUCTION 138 Object-oriented software construction (definition ... 138 OBJECT MOTTO 138 5.5 ISSUES 139 Finding the object types 139 Describing types and objects 140 Describing the relations and structuring software 140 5.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 141 5.7 BIBLIOGRAPHICAL NOTES 141 06 - ADTO9G.PDF 1 6 6 Abstract data types 143 6.1 CRITERIA 144 6.2 IMPLEMENTATION VARIATIONS 144 Stack representations 145 Three possible representations for a stack 145 Head-to-head representation for two stacks 146 The danger of overspecification 147 How long is a middle initial? 147 6.3 TOWARDS AN ABSTRACT VIEW OF OBJECTS 148 Using the operations 148 A laissez-faire policy for the society of modules 149 Name consistency 149 How not to handle abstractions 150 6.4 FORMALIZING THE SPECIFICATION 151 Specifying types 152 Genericity 153 Listing the functions 154 Applying the put function 155 Function categories 156 The AXIOMS paragraph 157 Applying the put function 158 Two or three things we know about stacks 159 Partial functions 160 Preconditions 160 The complete specification 161 ADT specification of stacks 161 Nothing but the truth 162 Stack manipulations 163 6.5 FROM ABSTRACT DATA TYPES TO CLASSES 164 Classes 164 Definition: class 164 Definition: deferred, effective class 164 How to produce an effective class 165 The role of deferred classes 165 Abstract data types and information hiding 166 The ADT view of a module under information hiding 166 Introducing a more imperative view 167 Back to square one? 168 Object-oriented software construction 169 Object-oriented software construction (definition ... 169 6.6 BEYOND SOFTWARE 169 6.7 SUPPLEMENTARY TOPICS 170 More on implicitness 171 Specification versus design 172 Definition: transition from analysis (specificatio... 172 Classes versus records 172 Alternatives to partial functions 173 Is my specification complete? 175 Definition: correct ADT expression 176 Definition: sufficient completeness 177 Definition: ADT consistency 177 Proving sufficient completeness 178 Weight Consistency rule 178 Definition: weight 179 Zero Weight rule 179 STACK AXIOMS 179 Canonical Reduction rule 180 6.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 181 6.9 BIBLIOGRAPHICAL NOTES 182 EXERCISES 183 E6.1 Points 183 E6.2 Boxers 183 E6.3 Bank accounts 183 E6.4 Messages 183 E6.5 Names 183 E6.6 Text 183 E6.7 Buying a house 184 E6.8 More stack operations 184 E6.9 Bounded stacks 184 E6.10 Queues 184 E6.11 Dispensers 184 E6.12 Booleans 184 E6.13 Sufficient completeness 184 E6.14 Consistency 184 07 - CLASSUU1.PDF 1 7 7 The static structure: classes 185 7.1 OBJECTS ARE NOT THE SUBJECT 185 Definition: class 185 7.2 AVOIDING THE STANDARD CONFUSION 186 What would you think of this? 186 The mold and the instance 187 Metaclasses 188 7.3 THE ROLE OF CLASSES 189 Modules and types 190 The class as module and type 190 7.4 A UNIFORM TYPE SYSTEM 191 Object rule 191 7.5 A SIMPLE CLASS 192 The features 192 A point and its coordinates 192 Attributes and routines 193 Representing a point in cartesian coordinates 193 Representing a point in polar coordinates 193 Feature classification, by role 194 Uniform access 195 Feature classification, by implementation 195 The class 196 7.6 BASIC CONVENTIONS 197 Recognizing feature kinds 197 Routine bodies and header comments 198 The indexing clause 198 Denoting a function’s result 199 Style rules 200 Inheriting general-purpose facilities 200 7.7 THE OBJECT-ORIENTED STYLE OF COMPUTATION 201 The current instance 201 Clients and suppliers 202 Definition: client, supplier 202 The origin 203 Feature call 203 Effect of calling a feature f on a target x 204 The Single Target principle 204 Single Target principle 204 The module-type identification 205 How the module-type merge works 205 The role of Current 205 Feature Call principle 206 Qualified and unqualified calls 206 Operator features 207 7.8 SELECTIVE EXPORTS AND INFORMATION HIDING 211 Full disclosure 211 Restricting client access 211 Style for declaring secret features 212 Exporting to yourself 213 7.9 PUTTING EVERYTHING TOGETHER 214 General relativity 214 The Big Bang 214 Definition: system execution 215 Systems 216 Definition: system closure 216 Not a main program 217 Assembling a system 218 A directory structure 219 Printing your name 220 Structure and order: the software developer as ars... 221 7.10 DISCUSSION 223 Form of declarations 223 Attributes vs. functions 224 Exporting attributes 225 The client’s privileges on an attribute 226 Possible client privileges on an attribute 227 Optimizing calls 228 The architectural role of selective exports 229 Listing imports 230 Denoting the result of a function 230 Complement: a precise definition of entities 233 Definition: entity 233 7.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 233 7.12 BIBLIOGRAPHICAL NOTES 235 EXERCISES 236 E7.1 Clarifying the terminology 236 E7.2 POINT as an abstract data type 236 E7.3 Completing POINT 236 E7.4 Polar coordinates 236 08 - OBJECO8I.PDF 1 8 8 The run-time structure: objects 237 8.1 OBJECTS 238 What is an object? 238 Definition: object 238 Basic form 239 Simple fields 240 A simple notion of book 241 An object representing a book 241 Writers 242 A “writer” object 242 References 242 Two “book” objects with “writer” subobjects 243 Two “book” objects with references to the same “wr... 244 Definition: reference 244 An object with a void reference field 244 Object identity 245 Declaring references 246 Self-reference 246 Direct and indirect self- reference 246 A look at the run-time object structure 247 A possible run- time object structure 247 8.2 OBJECTS AS A MODELING TOOL 248 The four worlds of software development 249 Molds and their instances 249 Reality: a cousin twice removed 250 8.3 MANIPULATING OBJECTS AND REFERENCES 251 Dynamic creation and reattachment 251 The creation instruction 252 Effect of a basic creation instruction 253 Default initialization values 253 A newly created and initialized object 254 The global picture 254 Why explicit creation? 255 8.4 CREATION PROCEDURES 256 Overriding the default initializations 256 Effect of a creation call 257 The export status of creation procedures 258 Rules on creation procedures 258 Multiple creation and overloading 259 8.5 MORE ON REFERENCES 260 States of a reference 260 The possible states of a reference 260 Void references and calls 260 8.6 OPERATIONS ON REFERENCES 262 Attaching a reference to an object 262 Before reference assignment 263 After reference assignment 263 Reference comparison 264 The void value 264 Object cloning and equality 265 De-attaching a reference from an object 265 Cloning an object 266 Object copying 267 Deep clone and comparison 267 Deep storage: a first view of persistence 270 Definition: direct dependents, dependents 270 Three mutually dependent objects 271 “Book” and “Writer” objects 271 Persistence Closure principle 272 8.7 COMPOSITE OBJECTS AND EXPANDED TYPES 274 References are not sufficient 274 Expanded types 274 A composite object with one subobject 275 Definition: expanded type 275 The role of expanded types 276 “Knows about” and “contains” relations between obj... 277 Aggregation 278 Properties of expanded types 278 Expanded Client rule 279 No references to subobjects 280 A subobject with a reference to another object 280 A reference to a subobject 281 8.8 ATTACHMENT: REFERENCE AND VALUE SEMANTICS 281 Attachment 281 Definition: attachment 282 Reference and copy attachment 282 Hybrid attachments 283 Effect of attachment x := y 284 Equality comparison 284 Meaning of comparison x = y 285 8.9 DEALING WITH REFERENCES: BENEFITS AND DANGERS 285 Dynamic aliasing 285 Sharing as a result of an attachment 286 The semantics of aliasing 286 Coming to terms with dynamic aliasing 287 Aliasing in software and elsewhere 288 A linked circular list 288 Encapsulating reference manipulations 289 8.10 DISCUSSION 290 Graphical conventions 291 References and simple values 292 Simula-style notations for operations on reference... 292 The form of clone and equality operations 294 The status of universal operations 296 8.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 296 8.12 BIBLIOGRAPHICAL NOTES 297 EXERCISES 297 E8.1 Books and authors 297 E8.2 Persons 297 E8.3 Notation design 298 09 - MEMORGMP.PDF 1 9 9 Memory management 299 9.1 WHAT HAPPENS TO OBJECTS 299 Object creation 299 Three modes of object management 300 The static mode 300 The stack- based mode 301 The free (heap- based) mode 301 Using the free mode 302 Space reclamation in the three modes 302 Allocation and deallocation in a block- structured... 303 Detachment 303 Detachment 303 Unreachable objects 304 Detachment is not always death 304 Reachable objects in classical approaches 305 Live objects (in color) and dead objects (in black... 306 Entity allocation for a procedure 307 Reachable objects in the object-oriented model 308 Reachability in the object- oriented model 308 Objects attached to local entities 309 The memory management problem in the object-orient... 310 Definition: origins, reachable and unreachable obj... 310 The three answers 310 9.2 THE CASUAL APPROACH 311 Can the casual approach be justified? 311 Do we care about memory any more? 311 A byte here, a byte there, and soon we will be tal... 312 9.3 RECLAIMING MEMORY: THE ISSUES 313 9.4 PROGRAMMER-CONTROLLED DEALLOCATION 314 The reliability issue 314 The ease of development issue 315 Direct and indirect self- reference 316 9.5 THE COMPONENT-LEVEL APPROACH 317 Managing space for a linked list 317 Dealing with recycled objects 319 Discussion 320 9.6 AUTOMATIC MEMORY MANAGEMENT 321 The need for automatic techniques 321 What exactly is reclamation? 322 9.7 REFERENCE COUNTING 322 Uncollectible cyclic structure 323 9.8 GARBAGE COLLECTION 324 The garbage collection mechanism 324 Garbage collector requirements 325 Garbage collector properties 325 Garbage collection basis 326 All-or-nothing collection 326 Advanced approaches to garbage collection 328 Parallel garbage collection algorithms 328 9.9 PRACTICAL ISSUES OF GARBAGE COLLECTION 329 Class MEMORY 329 A disposal mechanism 330 Garbage collection and external calls 331 9.10 AN ENVIRONMENT WITH MEMORY MANAGEMENT 332 Basics 332 Challenges 332 Object movement 333 Garbage collection mechanism 333 Bulimia and anorexia 334 Garbage collector operation 334 9.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 335 9.12 BIBLIOGRAPHICAL NOTES 335 EXERCISES 336 E9.1 Patterns of object creation 336 E9.2 What level of reclamation? 336 E9.3 Sharing the stack of available elements 336 E9.4 Sharing more 336 10 - GENERDE8.PDF 1 10 10 Genericity 337 Dimensions of generalization 337 10.1 HORIZONTAL AND VERTICAL TYPE GENERALIZATION 337 10.2 THE NEED FOR TYPE PARAMETERIZATION 338 Generic abstract data types 338 The issue 339 The role of typing 339 10.3 GENERIC CLASSES 340 Declaring a generic class 341 Using a generic class 342 Terminology 342 Type checking 343 The type rule 343 Operations on entities of generic types 344 Uses of entities of a formal generic type 344 Types and classes 345 10.4 ARRAYS 345 Arrays as objects 345 Array properties 346 Efficiency considerations 347 An infix synonym 348 10.5 THE COST OF GENERICITY 348 10.6 DISCUSSION: NOT DONE YET 349 10.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 350 10.8 BIBLIOGRAPHICAL NOTES 350 EXERCISES 350 E10.1 Constrained genericity 350 E10.2 Two-dimensional arrays 351 E10.3 Using your own formal generic parameter as s... 351 11 - CONTRE22.PDF 1 11 11 Design by Contract: building reliable softwa... 353 11.1 BASIC RELIABILITY MECHANISMS 354 11.2 ABOUT SOFTWARE CORRECTNESS 355 Software Correctness property 355 11.3 EXPRESSING A SPECIFICATION 356 Correctness formulae 356 Meaning of a correctness formula {P} A {Q} 357 Weak and strong conditions 357 Sinecure 1 358 Sinecure 2 358 11.4 INTRODUCING ASSERTIONS INTO SOFTWARE TEXTS 359 11.5 PRECONDITIONS AND POSTCONDITIONS 360 A stack class 360 Preconditions 362 Postconditions 362 A pedagogical note 362 11.6 CONTRACTING FOR SOFTWARE RELIABILITY 363 Rights and obligations 363 A routine contract: routine put for a stack class 364 Zen and the art of software reliability: guarantee... 364 Non-Redundancy principle 365 Assertions are not an input checking mechanism 367 Using filter modules 368 Assertions are not control structures 368 Assertion Violation rule (1) 368 Assertion violation rule (2) 369 Errors, defects and other creeping creatures 369 Terms to denote software woes 369 11.7 WORKING WITH ASSERTIONS 370 A stack class 370 Stack implemented with an array (see page 123 for ... 370 The imperative and the applicative 373 The imperative- applicative opposition 375 A note on empty structures 375 Precondition design: tolerant or demanding? 376 Reasonable Precondition principle 378 Preconditions and export status 379 Precondition Availability rule 380 A tolerant module 381 11.8 CLASS INVARIANTS 385 Definition and example 385 Form and properties of class invariants 386 The life of an object 387 An invariant that varies 388 Who must preserve the invariant? 388 Invariant rule 388 The role of class invariants in software engineeri... 389 Invariants and contracting 390 11.9 WHEN IS A CLASS CORRECT? 391 The correctness of a class 391 Definition: class correctness 392 The life of an object 392 (This figure first appeared on page 366.) 392 The role of creation procedures 393 Arrays revisited 394 11.10 THE ADT CONNECTION 395 Not just a collection of functions 395 Class features vs. ADT functions 396 Expressing the axioms 396 The abstraction function 397 Transformations 397 on abstract and concrete objects 397 Class-ADT Consistency property 397 Implementation invariants 398 Same abstract object, two representations 399 11.11 AN ASSERTION INSTRUCTION 400 11.12 LOOP INVARIANTS AND VARIANTS 402 Loop trouble 402 Four (wrong) attempts at binary search. 403 From [M 1990] 403 Getting loops right 404 Approximating an array by successive slices 405 Ingredients for a provably correct loop 405 A loop computation (from [M 1990]) 406 Loop syntax 408 11.13 USING ASSERTIONS 411 Assertions as a tool for writing correct software 411 Using assertions for documentation: the short form... 411 Monitoring assertions at run time 414 How much assertion monitoring? 416 11.14 DISCUSSION 420 Why run-time monitoring? 420 The expressive power of assertions 421 Including functions in assertions 422 Assertion Evaluation rule 425 Class invariants and reference semantics 425 Consistency of forward and backward references 426 Violating the invariant 427 More to come 428 11.15 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 428 11.16 BIBLIOGRAPHICAL NOTES 429 EXERCISES 430 E11.1 Complex numbers 430 E11.2 A class and its ADT 430 E11.3 Complete assertions for stacks 431 E11.4 Exporting the size 431 E11.5 An implementation invariant 431 E11.6 Assertions and exports 431 E11.7 Finding the bugs 431 E11.8 Invariant violations 431 E11.9 Random number generators 431 E11.10 A queue module 432 E11.11 A set module 432 POSTSCRIPT: THE ARIANE 5 CRASH 432 12 - EXCEP1NG.PDF 1 12 12 When the contract is broken: exception handl... 433 12.1 BASIC CONCEPTS OF EXCEPTION HANDLING 433 Failures 433 Definitions: success, failure 434 Exceptions 434 Definition: exception 434 Sources of exceptions 434 Definition: exception cases 435 Failures and exceptions 435 Causes of failure 435 Definition: failure cases 436 12.2 HANDLING EXCEPTIONS 436 How not to do it — a C-Unix example 436 How not to do it — an Ada example 437 Ada Exception rule 438 Exception handling principles 439 Disciplined Exception Handling principle 439 The call chain 440 The call chain 440 12.3 AN EXCEPTION MECHANISM 441 Rescue and Retry 441 How to fail without really trying 442 Failure principle 442 An exception history table 442 An exception history table 443 12.4 EXCEPTION HANDLING EXAMPLES 444 A failed execution 444 Fragile input 444 Recovering from hardware or operating system excep... 445 Retrying for software fault tolerance 446 N-version programming 448 12.5 THE TASK OF A RESCUE CLAUSE 449 The correctness of a rescue clause 449 The life of an object 450 Correctness rule for failure-inducing rescue claus... 451 Correctness rule for retry-inducing rescue clauses... 451 A clear separation of roles 451 When there is no rescue clause 452 12.6 ADVANCED EXCEPTION HANDLING 453 Exception queries 453 How fine a degree of control? 456 Exception Simplicity principle 456 Developer exceptions 456 12.7 DISCUSSION 457 Disciplined exceptions 458 Should exceptions be objects? 458 The methodological perspective 459 12.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 459 12.9 BIBLIOGRAPHICAL NOTES 460 EXERCISES 460 E12.1 Largest integer 460 E12.2 Exception objects 460 13 - MECHADU5.PDF 1 13 13 Supporting mechanisms 461 13.1 INTERFACING WITH NON-O-O SOFTWARE 461 External routines 461 Advanced variants 462 Uses of external routines 463 Object-oriented re-architecturing 463 The compatibility issue: hybrid software or hybrid... 465 13.2 ARGUMENT PASSING 466 Permissible operations on a reference argument 467 13.3 INSTRUCTIONS 469 Procedure call 469 Qualified Call rule 469 Assignment 470 Creation instruction 470 Conditional 470 Multi-branch 471 Loop 473 Check 474 Debug 474 Retry 474 13.4 EXPRESSIONS 474 Manifest constants 474 Function calls 475 Current object 475 Expressions with operators 475 Non-strict boolean operators 476 Non-strict boolean operators 476 13.5 STRINGS 478 13.6 INPUT AND OUTPUT 479 13.7 LEXICAL CONVENTIONS 479 13.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 480 EXERCISES 480 E13.1 External classes 480 E13.2 Avoiding non-strict operators 480 14 - INHVJG.PDF 1 14 14 Introduction to inheritance 483 14.1 POLYGONS AND RECTANGLES 484 Polygons 484 Rectangles 486 Basic conventions and terminology 488 Inheritance terminology 488 An inheritance link 488 Invariant inheritance 489 Invariant inheritance rule 489 Inheritance and creation 489 Creation Inheritance rule 490 An example hierarchy 491 14.2 POLYMORPHISM 491 Polymorphic attachment 491 Figure type hierarchy 492 What exactly happens during a polymorphic attachme... 493 Polymorphic reference reattachment 493 Polymorphic data structures 494 A polymorphic array 495 Dimensions of generalization 495 14.3 TYPING FOR INHERITANCE 496 Type consistency 496 Feature Call rule 497 Limits to polymorphism 498 Definition: conformance 498 Type Conformance rule 498 Instances 499 Definition: direct instance, instance 499 Static-dynamic type consistency 499 Static type, dynamic type 499 Are the restrictions justified? 500 Can ignorance be bliss? 501 After a polymorphic 501 attachment 501 When you want to force a type 502 Polymorphic creation 503 14.4 DYNAMIC BINDING 504 Using the right variant 504 Redefinition and assertions 505 On the implementation of dynamic binding 506 14.5 DEFERRED FEATURES AND CLASSES 506 Moving arbitrary figures 506 The FIGURE hierarchy again 507 Deferring a feature 508 Effecting a feature 508 Definition: redeclaration 509 Deferred classes 510 Definition: deferred, effective class 510 Deferred class declaration rule 510 Graphical conventions 511 What to do with deferred classes 511 Deferred Class No-Instantiation rule 511 Specifying the semantics of deferred features and ... 512 List with cursor 512 Cursor positions 514 14.6 REDECLARATION TECHNIQUES 515 Redeclaring a function into an attribute 515 Not the other way around 516 Using the original version in a redefinition 517 14.7 THE MEANING OF INHERITANCE 518 The dual perspective 518 Inheritance mechanisms and their role 519 The module view 519 Draft structure for a table library 521 The type view 521 Inheritance and decentralization 522 Representation independence 524 The extension-specialization paradox 524 14.8 THE ROLE OF DEFERRED CLASSES 525 Back to abstract data types 525 Deferred classes as partial implementations: the n... 528 Variants of the notion of table 528 Don’t call us, we’ll call you 529 Programs with holes 530 Deferred classes for analysis and global design 531 14.9 DISCUSSION 532 Explicit redefinition 532 Accessing the precursor of a routine 532 Dynamic binding and efficiency 532 Estimating the overhead 534 Static binding as an optimization 535 A button by any other name: when static binding is... 536 Dynamic Binding principle 536 A parent version may fail to satisfy the new invar... 538 The C++ approach to binding 538 14.10 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 541 14.11 BIBLIOGRAPHICAL NOTES 542 EXERCISES 542 E14.1 Polygons and rectangles 542 E14.2 How few vertices for a polygon? 542 E14.3 Geometrical objects with two coordinates 543 E14.4 Inheritance without classes 543 E14.5 Non-creatable classes 543 E14.6 Deferred classes and rapid prototyping 543 E14.7 Table searching library (term project) 543 E14.8 Kinds of deferred feature 543 E14.9 Complex numbers 544 15 - INH_MFJE.PDF 1 15 15 Multiple inheritance 545 15.1 EXAMPLES OF MULTIPLE INHERITANCE 545 What not to use as an introductory example 546 A case of multiple inheritanceo 546 o that is a case of repeated inheritance 546 Can an airplane be an asset? 547 Company planes 547 Numeric and comparable values 548 Windows are trees and rectangles 550 Multiple structure inheritance 550 Windows and subwindows 550 Trees are lists and list elements 551 A tree of integers 552 Definition: tree 552 Composite figures 553 Elementary figures 553 A composite figure 553 A composite figure is a figure and a list of figur... 554 The marriage of convenience 556 A marriage of convenience 556 Structure inheritance 558 Facility inheritance 558 Buttonholes 559 Pick-and- throw 560 An assessment 560 15.2 FEATURE RENAMING 561 Name clashes 561 Effects of renaming 563 A name clash, removed 563 Renaming and redeclaration 564 Local name adaptation 564 The game of the name 565 Using a parent’s creation procedure 565 15.3 FLATTENING THE STRUCTURE 567 The flat form 567 Displaying a flat form 568 Uses of the flat form 568 The flat-short form 569 15.4 REPEATED INHERITANCE 569 Sharing ancestors 569 Repeated inheritance 569 Intercontinental drivers 570 Sharing and replication 570 Kinds of driver 571 Repeated Inheritance rule 572 Sharing and replication 573 Attribute replication 573 Unobtrusive repeated inheritance 574 Redundant inheritance 574 The renaming rule 575 Definition: final name 575 Single Name rule 575 Conflicting redefinitions 577 Redefinition causing potential ambiguity 577 Conflicts under sharing: undefinition and join 577 Two parents with features to be merged 578 Conflicts under replication: selection 579 The need for selection 579 Select rule 581 Selecting everything 581 Keeping the original version of a redefined featur... 581 An advanced example 583 Window variants 584 Repeated inheritance and genericity 587 Genericity in Repeated Inheritance rule 588 Rules on names 588 Name clashes: definition and rule 588 15.5 DISCUSSION 589 Renaming 589 O-O development and overloading 590 15.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 592 15.7 BIBLIOGRAPHICAL NOTES 593 EXERCISES 593 E15.1 Windows as trees 593 E15.2 Is a window a string? 593 E15.3 Doing windows fully 593 E15.4 Figure iterators 593 E15.5 Linked stacks 593 E15.6 Circular lists and chains 593 E15.7 Trees 594 E15.8 Walking menus 594 Walking menus 594 E15.9 The flat precursor 594 E15.10 Repeated inheritance for replication 594 16 - INH_MF75.PDF 1 16 16 Inheritance techniques 595 16.1 INHERITANCE AND ASSERTIONS 595 Invariants 596 Parents’ Invariant rule 596 Preconditions and postconditions in the presence o... 596 The routine, the client and the contract 596 The routine, the client, the contract and the desc... 597 How to cheat clients 598 How to be honest 599 Assertion Redeclaration rule (1) 599 An example 599 Cutting out the middleman 601 The routine, the client and the sub- contractor 601 Subcontracting 602 Abstract preconditions 602 The language rule 604 Assertion Redeclaration rule (2) 604 Redeclaring into attributes 605 A mathematical note 606 16.2 THE GLOBAL INHERITANCE STRUCTURE 606 Universal classes 606 Universal Class rule 606 The global inheritance struct OOSC_IND.PDF......Page 0 Contents......Page 15 Preface......Page 3 Simple but powerful......Page 4 Organization of the text......Page 5 A Book-Wide Web......Page 6 The notation......Page 7 The environment......Page 8 Acknowledgments (quasi-absence thereof)......Page 9 Foreword to the second edition......Page 10 About the accompanying CD-ROM......Page 11 On the bibliography, Internet sources and exercise.........Page 13 1.1 EXTERNAL AND INTERNAL FACTORS......Page 27 Layers in software development......Page 28 Robustness versus correctness......Page 29 Definition: extendibility......Page 30 Definition: reusability......Page 31 Definition: compatibility......Page 32 Definition: efficiency......Page 33 Definition: ease of use......Page 35 Definition: functionality......Page 36 Osmond’s curves; after [Osmond 1995]......Page 37 About documentation......Page 38 Key concerns......Page 39 Breakdown of maintenance costs. Source: [Lientz 19.........Page 41 1.5 BIBLIOGRAPHICAL NOTES......Page 43 How dogmatic do we need to be?......Page 45 Seamlessness......Page 46 Assertions......Page 47 Feature-based computation......Page 48 Static typing......Page 49 Multiple inheritance......Page 50 Constrained genericity......Page 51 Polymorphism......Page 52 Run-time type interrogation......Page 53 Memory management and garbage collection......Page 54 Fast update......Page 55 Documentation......Page 56 Graphics and user interfaces......Page 57 2.6 BIBLIOGRAPHICAL NOTES AND OBJECT RESOURCES......Page 58 3 3 Modularity......Page 61 Decomposability......Page 62 A top-down hierarchy......Page 63 Composability......Page 64 Understan- dability......Page 65 Modular continuity......Page 66 Modular protection......Page 67 3.2 FIVE RULES......Page 68 Types of module interconnection structures......Page 69 Communication bandwidth between modules......Page 70 Data sharing......Page 72 A module under Information Hiding......Page 73 Linguistic Modular Units principle......Page 75 Self-Documentation principle......Page 76 Uniform Access......Page 77 Two representation for a bank account......Page 78 Open-Closed principle......Page 79 Old and new clients......Page 80 Adapting a module to new clients......Page 82 Single Choice......Page 83 Single Choice principle......Page 85 3.5 BIBLIOGRAPHICAL NOTES......Page 86 E3.4 Metrics for modularity (term project)......Page 87 E3.6 Configuration management and inheritance......Page 88 4 4 Approaches to reusability......Page 89 Expected benefits......Page 90 Reuse consumers, reuse producers......Page 91 Reuse of designs and specifications......Page 92 Design patterns......Page 93 Reusability through the source code......Page 94 Reuse of abstracted modules......Page 95 4.4 NON-TECHNICAL OBSTACLES......Page 96 The NIH syndrome......Page 97 Software companies and their strategies......Page 98 Accessing components......Page 99 A note about component indexing......Page 100 Formats for reusable component distribution......Page 101 Change and constancy......Page 103 The reuse-redo dilemma......Page 104 4.6 FIVE REQUIREMENTS ON MODULE STRUCTURES......Page 105 Representation Independence......Page 106 Factoring Out Common Behaviors......Page 107 Some possible table implementations......Page 108 Array representation of sequential table with cur.........Page 109 Sequential file representation of a sequential tab.........Page 110 Routines......Page 111 Packages......Page 112 Packages: an assessment......Page 114 Syntactic overloading......Page 115 Role of overloading......Page 116 Semantic overloading (a preview)......Page 117 Genericity......Page 118 Basic modularity techniques: an assessment......Page 119 4.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 120 4.10 BIBLIOGRAPHICAL NOTES......Page 121 The three forces of computation......Page 123 Continuity......Page 125 Top-down development......Page 126 Not just one function......Page 127 Structure of a simple payroll program......Page 128 Finding the top......Page 129 Functions and evolution......Page 130 Interfaces and software design......Page 131 Premature ordering......Page 132 Ordering and O-O development......Page 133 Reusability......Page 134 The context of a module in top-down design......Page 135 5.3 OBJECT-BASED DECOMPOSITION......Page 136 Compatibility......Page 137 OBJECT MOTTO......Page 138 Finding the object types......Page 139 Describing the relations and structuring software......Page 140 5.7 BIBLIOGRAPHICAL NOTES......Page 141 6 6 Abstract data types......Page 143 6.2 IMPLEMENTATION VARIATIONS......Page 144 Three possible representations for a stack......Page 145 Head-to-head representation for two stacks......Page 146 How long is a middle initial?......Page 147 Using the operations......Page 148 Name consistency......Page 149 How not to handle abstractions......Page 150 6.4 FORMALIZING THE SPECIFICATION......Page 151 Specifying types......Page 152 Genericity......Page 153 Listing the functions......Page 154 Applying the put function......Page 155 Function categories......Page 156 The AXIOMS paragraph......Page 157 Applying the put function......Page 158 Two or three things we know about stacks......Page 159 Preconditions......Page 160 ADT specification of stacks......Page 161 Nothing but the truth......Page 162 Stack manipulations......Page 163 Definition: deferred, effective class......Page 164 The role of deferred classes......Page 165 The ADT view of a module under information hiding......Page 166 Introducing a more imperative view......Page 167 Back to square one?......Page 168 6.6 BEYOND SOFTWARE......Page 169 6.7 SUPPLEMENTARY TOPICS......Page 170 More on implicitness......Page 171 Classes versus records......Page 172 Alternatives to partial functions......Page 173 Is my specification complete?......Page 175 Definition: correct ADT expression......Page 176 Definition: ADT consistency......Page 177 Weight Consistency rule......Page 178 STACK AXIOMS......Page 179 Canonical Reduction rule......Page 180 6.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 181 6.9 BIBLIOGRAPHICAL NOTES......Page 182 E6.6 Text......Page 183 E6.14 Consistency......Page 184 Definition: class......Page 185 What would you think of this?......Page 186 The mold and the instance......Page 187 Metaclasses......Page 188 7.3 THE ROLE OF CLASSES......Page 189 The class as module and type......Page 190 Object rule......Page 191 A point and its coordinates......Page 192 Representing a point in polar coordinates......Page 193 Feature classification, by role......Page 194 Feature classification, by implementation......Page 195 The class......Page 196 Recognizing feature kinds......Page 197 The indexing clause......Page 198 Denoting a function’s result......Page 199 Inheriting general-purpose facilities......Page 200 The current instance......Page 201 Definition: client, supplier......Page 202 Feature call......Page 203 Single Target principle......Page 204 The role of Current......Page 205 Qualified and unqualified calls......Page 206 Operator features......Page 207 Restricting client access......Page 211 Style for declaring secret features......Page 212 Exporting to yourself......Page 213 The Big Bang......Page 214 Definition: system execution......Page 215 Definition: system closure......Page 216 Not a main program......Page 217 Assembling a system......Page 218 A directory structure......Page 219 Printing your name......Page 220 Structure and order: the software developer as ars.........Page 221 Form of declarations......Page 223 Attributes vs. functions......Page 224 Exporting attributes......Page 225 The client’s privileges on an attribute......Page 226 Possible client privileges on an attribute......Page 227 Optimizing calls......Page 228 The architectural role of selective exports......Page 229 Denoting the result of a function......Page 230 7.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 233 7.12 BIBLIOGRAPHICAL NOTES......Page 235 E7.4 Polar coordinates......Page 236 8 8 The run-time structure: objects......Page 237 Definition: object......Page 238 Basic form......Page 239 Simple fields......Page 240 An object representing a book......Page 241 References......Page 242 Two “book” objects with “writer” subobjects......Page 243 An object with a void reference field......Page 244 Object identity......Page 245 Direct and indirect self- reference......Page 246 A possible run- time object structure......Page 247 8.2 OBJECTS AS A MODELING TOOL......Page 248 Molds and their instances......Page 249 Reality: a cousin twice removed......Page 250 Dynamic creation and reattachment......Page 251 The creation instruction......Page 252 Default initialization values......Page 253 The global picture......Page 254 Why explicit creation?......Page 255 Overriding the default initializations......Page 256 Effect of a creation call......Page 257 Rules on creation procedures......Page 258 Multiple creation and overloading......Page 259 Void references and calls......Page 260 Attaching a reference to an object......Page 262 After reference assignment......Page 263 The void value......Page 264 De-attaching a reference from an object......Page 265 Cloning an object......Page 266 Deep clone and comparison......Page 267 Definition: direct dependents, dependents......Page 270 “Book” and “Writer” objects......Page 271 Persistence Closure principle......Page 272 Expanded types......Page 274 Definition: expanded type......Page 275 The role of expanded types......Page 276 “Knows about” and “contains” relations between obj.........Page 277 Properties of expanded types......Page 278 Expanded Client rule......Page 279 A subobject with a reference to another object......Page 280 Attachment......Page 281 Reference and copy attachment......Page 282 Hybrid attachments......Page 283 Equality comparison......Page 284 Dynamic aliasing......Page 285 The semantics of aliasing......Page 286 Coming to terms with dynamic aliasing......Page 287 A linked circular list......Page 288 Encapsulating reference manipulations......Page 289 8.10 DISCUSSION......Page 290 Graphical conventions......Page 291 Simula-style notations for operations on reference.........Page 292 The form of clone and equality operations......Page 294 8.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 296 E8.2 Persons......Page 297 E8.3 Notation design......Page 298 Object creation......Page 299 The static mode......Page 300 The free (heap- based) mode......Page 301 Space reclamation in the three modes......Page 302 Detachment......Page 303 Detachment is not always death......Page 304 Reachable objects in classical approaches......Page 305 Live objects (in color) and dead objects (in black.........Page 306 Entity allocation for a procedure......Page 307 Reachability in the object- oriented model......Page 308 Objects attached to local entities......Page 309 The three answers......Page 310 Do we care about memory any more?......Page 311 A byte here, a byte there, and soon we will be tal.........Page 312 9.3 RECLAIMING MEMORY: THE ISSUES......Page 313 The reliability issue......Page 314 The ease of development issue......Page 315 Direct and indirect self- reference......Page 316 Managing space for a linked list......Page 317 Dealing with recycled objects......Page 319 Discussion......Page 320 The need for automatic techniques......Page 321 9.7 REFERENCE COUNTING......Page 322 Uncollectible cyclic structure......Page 323 The garbage collection mechanism......Page 324 Garbage collector properties......Page 325 All-or-nothing collection......Page 326 Parallel garbage collection algorithms......Page 328 Class MEMORY......Page 329 A disposal mechanism......Page 330 Garbage collection and external calls......Page 331 Challenges......Page 332 Garbage collection mechanism......Page 333 Garbage collector operation......Page 334 9.12 BIBLIOGRAPHICAL NOTES......Page 335 E9.4 Sharing more......Page 336 10.1 HORIZONTAL AND VERTICAL TYPE GENERALIZATION......Page 337 Generic abstract data types......Page 338 The role of typing......Page 339 10.3 GENERIC CLASSES......Page 340 Declaring a generic class......Page 341 Terminology......Page 342 The type rule......Page 343 Uses of entities of a formal generic type......Page 344 Arrays as objects......Page 345 Array properties......Page 346 Efficiency considerations......Page 347 10.5 THE COST OF GENERICITY......Page 348 10.6 DISCUSSION: NOT DONE YET......Page 349 E10.1 Constrained genericity......Page 350 E10.3 Using your own formal generic parameter as s.........Page 351 11 11 Design by Contract: building reliable softwa.........Page 353 11.1 BASIC RELIABILITY MECHANISMS......Page 354 Software Correctness property......Page 355 Correctness formulae......Page 356 Weak and strong conditions......Page 357 Sinecure 2......Page 358 11.4 INTRODUCING ASSERTIONS INTO SOFTWARE TEXTS......Page 359 A stack class......Page 360 A pedagogical note......Page 362 Rights and obligations......Page 363 Zen and the art of software reliability: guarantee.........Page 364 Non-Redundancy principle......Page 365 Assertions are not an input checking mechanism......Page 367 Assertion Violation rule (1)......Page 368 Terms to denote software woes......Page 369 Stack implemented with an array (see page 123 for .........Page 370 The imperative and the applicative......Page 373 A note on empty structures......Page 375 Precondition design: tolerant or demanding?......Page 376 Reasonable Precondition principle......Page 378 Preconditions and export status......Page 379 Precondition Availability rule......Page 380 A tolerant module......Page 381 Definition and example......Page 385 Form and properties of class invariants......Page 386 The life of an object......Page 387 Invariant rule......Page 388 The role of class invariants in software engineeri.........Page 389 Invariants and contracting......Page 390 The correctness of a class......Page 391 (This figure first appeared on page 366.)......Page 392 The role of creation procedures......Page 393 Arrays revisited......Page 394 Not just a collection of functions......Page 395 Expressing the axioms......Page 396 Class-ADT Consistency property......Page 397 Implementation invariants......Page 398 Same abstract object, two representations......Page 399 11.11 AN ASSERTION INSTRUCTION......Page 400 Loop trouble......Page 402 From [M 1990]......Page 403 Getting loops right......Page 404 Ingredients for a provably correct loop......Page 405 A loop computation (from [M 1990])......Page 406 Loop syntax......Page 408 Using assertions for documentation: the short form.........Page 411 Monitoring assertions at run time......Page 414 How much assertion monitoring?......Page 416 Why run-time monitoring?......Page 420 The expressive power of assertions......Page 421 Including functions in assertions......Page 422 Class invariants and reference semantics......Page 425 Consistency of forward and backward references......Page 426 Violating the invariant......Page 427 11.15 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 428 11.16 BIBLIOGRAPHICAL NOTES......Page 429 E11.2 A class and its ADT......Page 430 E11.9 Random number generators......Page 431 POSTSCRIPT: THE ARIANE 5 CRASH......Page 432 Failures......Page 433 Sources of exceptions......Page 434 Causes of failure......Page 435 How not to do it — a C-Unix example......Page 436 How not to do it — an Ada example......Page 437 Ada Exception rule......Page 438 Disciplined Exception Handling principle......Page 439 The call chain......Page 440 Rescue and Retry......Page 441 An exception history table......Page 442 An exception history table......Page 443 Fragile input......Page 444 Recovering from hardware or operating system excep.........Page 445 Retrying for software fault tolerance......Page 446 N-version programming......Page 448 The correctness of a rescue clause......Page 449 The life of an object......Page 450 A clear separation of roles......Page 451 When there is no rescue clause......Page 452 Exception queries......Page 453 Developer exceptions......Page 456 12.7 DISCUSSION......Page 457 Should exceptions be objects?......Page 458 12.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 459 E12.2 Exception objects......Page 460 External routines......Page 461 Advanced variants......Page 462 Object-oriented re-architecturing......Page 463 The compatibility issue: hybrid software or hybrid.........Page 465 13.2 ARGUMENT PASSING......Page 466 Permissible operations on a reference argument......Page 467 Qualified Call rule......Page 469 Conditional......Page 470 Multi-branch......Page 471 Loop......Page 473 Manifest constants......Page 474 Expressions with operators......Page 475 Non-strict boolean operators......Page 476 13.5 STRINGS......Page 478 13.7 LEXICAL CONVENTIONS......Page 479 E13.2 Avoiding non-strict operators......Page 480 14 14 Introduction to inheritance......Page 483 Polygons......Page 484 Rectangles......Page 486 An inheritance link......Page 488 Inheritance and creation......Page 489 Creation Inheritance rule......Page 490 Polymorphic attachment......Page 491 Figure type hierarchy......Page 492 Polymorphic reference reattachment......Page 493 Polymorphic data structures......Page 494 Dimensions of generalization......Page 495 Type consistency......Page 496 Feature Call rule......Page 497 Type Conformance rule......Page 498 Static type, dynamic type......Page 499 Are the restrictions justified?......Page 500 attachment......Page 501 When you want to force a type......Page 502 Polymorphic creation......Page 503 Using the right variant......Page 504 Redefinition and assertions......Page 505 Moving arbitrary figures......Page 506 The FIGURE hierarchy again......Page 507 Effecting a feature......Page 508 Definition: redeclaration......Page 509 Deferred class declaration rule......Page 510 Deferred Class No-Instantiation rule......Page 511 List with cursor......Page 512 Cursor positions......Page 514 Redeclaring a function into an attribute......Page 515 Not the other way around......Page 516 Using the original version in a redefinition......Page 517 The dual perspective......Page 518 The module view......Page 519 The type view......Page 521 Inheritance and decentralization......Page 522 The extension-specialization paradox......Page 524 Back to abstract data types......Page 525 Variants of the notion of table......Page 528 Don’t call us, we’ll call you......Page 529 Programs with holes......Page 530 Deferred classes for analysis and global design......Page 531 Dynamic binding and efficiency......Page 532 Estimating the overhead......Page 534 Static binding as an optimization......Page 535 Dynamic Binding principle......Page 536 The C++ approach to binding......Page 538 14.10 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 541 E14.2 How few vertices for a polygon?......Page 542 E14.8 Kinds of deferred feature......Page 543 E14.9 Complex numbers......Page 544 15.1 EXAMPLES OF MULTIPLE INHERITANCE......Page 545 o that is a case of repeated inheritance......Page 546 Company planes......Page 547 Numeric and comparable values......Page 548 Windows and subwindows......Page 550 Trees are lists and list elements......Page 551 Definition: tree......Page 552 A composite figure......Page 553 A composite figure is a figure and a list of figur.........Page 554 A marriage of convenience......Page 556 Facility inheritance......Page 558 Buttonholes......Page 559 An assessment......Page 560 Name clashes......Page 561 A name clash, removed......Page 563 Local name adaptation......Page 564 Using a parent’s creation procedure......Page 565 The flat form......Page 567 Uses of the flat form......Page 568 Repeated inheritance......Page 569 Sharing and replication......Page 570 Kinds of driver......Page 571 Repeated Inheritance rule......Page 572 Attribute replication......Page 573 Redundant inheritance......Page 574 Single Name rule......Page 575 Conflicts under sharing: undefinition and join......Page 577 Two parents with features to be merged......Page 578 The need for selection......Page 579 Keeping the original version of a redefined featur.........Page 581 An advanced example......Page 583 Window variants......Page 584 Repeated inheritance and genericity......Page 587 Name clashes: definition and rule......Page 588 Renaming......Page 589 O-O development and overloading......Page 590 15.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 592 E15.6 Circular lists and chains......Page 593 E15.10 Repeated inheritance for replication......Page 594 16.1 INHERITANCE AND ASSERTIONS......Page 595 The routine, the client and the contract......Page 596 The routine, the client, the contract and the desc.........Page 597 How to cheat clients......Page 598 An example......Page 599 The routine, the client and the sub- contractor......Page 601 Abstract preconditions......Page 602 Assertion Redeclaration rule (2)......Page 604 Redeclaring into attributes......Page 605 Universal Class rule......Page 606 The global inheritance structure......Page 607 Universal features......Page 608 Fixed semantics for copy, clone and equality featu.........Page 609 Addable vectors......Page 611 Adding two vectors, item by item......Page 613 Constraining the generic parameter......Page 614 Unconstrained genericity revisited......Page 616 When type rules become obnoxious......Page 617 The challenge......Page 618 The mechanism......Page 619 Using assignment attempt properly......Page 621 Devices and printers......Page 622 A linkable cell......Page 623 Parallel hierarchies......Page 624 Type inconsistencies......Page 625 Application-oriented examples......Page 626 A serious problem......Page 627 The notion of anchor......Page 628 Base classes revisited......Page 629 When not to use anchored declaration......Page 630 A static mechanism......Page 631 Applications......Page 632 Why the flexibility?......Page 633 Interface and implementation reuse......Page 634 The two styles......Page 635 16.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 636 E16.3 Extract?......Page 637 The Basic Construct......Page 639 Definition: statically typed language......Page 640 Realism......Page 641 Pessimism......Page 642 After [Boehm 1981]. Reproduced with permission.......Page 643 The ingredients of successful typing......Page 644 Multiple inheritance......Page 645 “A little bit typed”?......Page 646 Typing and binding......Page 647 Kinds of flying object......Page 648 Covariance......Page 649 Kinds of skier......Page 650 Skier hierarchy and redefinitions......Page 652 Parallel hierarchies......Page 653 Polymorphic perversity......Page 654 Descendant hiding......Page 655 Practical scope......Page 656 Using generic parameters......Page 657 17.5 RELYING ON ANCHORED TYPES......Page 658 17.6 GLOBAL ANALYSIS......Page 662 System Validity rule......Page 663 Catcall type rule......Page 665 Definition: Polymorphic entity......Page 666 17.8 AN ASSESSMENT......Page 667 17.9 THE PERFECT FIT......Page 668 17.11 BIBLIOGRAPHICAL NOTES......Page 670 18.1 CONSTANTS OF BASIC TYPES......Page 673 Constant attributes......Page 674 18.2 USE OF CONSTANTS......Page 675 Manifest constants are inappropriate for class typ.........Page 676 Once functions......Page 677 Shared objects......Page 678 Once functions returning results of basic types......Page 680 Arguments......Page 681 Once functions, anchoring and genericity......Page 682 18.5 CONSTANTS OF STRING TYPE......Page 683 18.6 UNIQUE VALUES......Page 684 Discrimination principle......Page 685 Initializing globals and shared objects: language .........Page 686 Unique values and enumerated types......Page 687 18.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 689 E18.4 Once attributes?......Page 690 19.1 SOFTWARE METHODOLOGY: WHY AND WHAT......Page 691 The need for methodology guidelines......Page 692 Practical Basis methodology principle......Page 693 Absolute positives......Page 694 Advisories......Page 695 Exceptions......Page 696 Abstraction and precision......Page 697 If it is baroque, fix it......Page 698 19.3 ON USING METAPHORS......Page 699 19.4 THE IMPORTANCE OF BEING HUMBLE......Page 701 E19.4 Metaphors on the Net......Page 702 20.1 MULTI-PANEL SYSTEMS......Page 705 A panel......Page 706 A transition diagram......Page 707 The transition function......Page 708 The routine architecture......Page 709 Top-down functional decomposition......Page 710 Statism......Page 712 The flow of data......Page 713 State as a class......Page 714 features......Page 715 Inheritance and deferred classes......Page 716 State class hierarchy......Page 717 Describing a complete system......Page 718 STATE and APPLICATION features......Page 719 The application class......Page 720 A polymorphic array of states......Page 722 20.6 DISCUSSION......Page 723 20.7 BIBLIOGRAPHICAL NOTE......Page 724 Undoing for fun and profit......Page 725 Practical issues......Page 726 Requirements on the solution......Page 727 Command as a class......Page 729 Command class hierarchy......Page 730 The basic interactive step......Page 731 Remembering the last command......Page 732 How to create a command object......Page 733 The history list......Page 734 Implementing Undo......Page 735 Implementing Redo......Page 736 Command arguments......Page 737 Precomputing command objects......Page 738 The array of command templates......Page 739 Bounded circular list implemented by an array......Page 740 A history window, before any undoing......Page 741 21.6 DISCUSSION......Page 742 The role of implementation......Page 743 Small classes......Page 744 E21.1 Putting together a small interactive system .........Page 745 E21.6 Composite commands......Page 746 E21.9 A history mechanism......Page 747 E21.11 Integrable functions......Page 748 22 22 How to find the classes......Page 749 Avoiding useless classes......Page 750 Is a new class necessary?......Page 751 Missing important classes......Page 753 Class Elicitation principle......Page 755 My class performso......Page 756 Class Name rule......Page 757 Premature classification......Page 758 No-command classes......Page 759 The ideal class......Page 760 Class categories......Page 761 External objects: finding the analysis classes......Page 762 Finding the implementation classes......Page 763 Finding the design classes......Page 764 Adaptation through inheritance......Page 765 Hints from other approaches......Page 766 Files......Page 767 Use cases......Page 768 Use Case principle......Page 769 The bottom-up component......Page 770 22.6 THE METHOD FOR OBTAINING CLASSES......Page 771 Sources of possible classes......Page 772 22.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER......Page 773 22.8 BIBLIOGRAPHICAL NOTES......Page 774 E22.1 Floors as integers......Page 775 E22.2 Inspecting objects......Page 776 23 23 Principles of class design......Page 777 Forms of side effect......Page 778 Referential transparency......Page 779 Definition: referential transparency......Page 780 A list object as list machine......Page 781 A clean style for class interfaces......Page 782 Pseudo-random number generators: a design exercise.........Page 784 An infinite list as a machine......Page 785 Abstract state, concrete state......Page 786 Definition: abstract side effect......Page 787 Objections......Page 788 Legitimate side effects: an example......Page 789 The importance of argument counts......Page 794 Definition: operand and option arguments......Page 796 Operand principle......Page 797 Exceptions to the Operand principle?......Page 799 23.3 CLASS SIZE: THE SHOPPING LIST APPROACH......Page 800 Maintaining consistency......Page 801 Shopping List advice......Page 802 Laxity and restrictiveness......Page 803 Linked list representation......Page 804 Deletion in a linked list......Page 805 Passive classes......Page 806 Encapsulation and assertions......Page 810 Simple-minded solutions......Page 811 Evolution of a library class......Page 812 List with cursor......Page 813 Maintaining consistency: the implementation invari.........Page 814 List with sentinels......Page 815 The client’s view......Page 816 Cursor list representation (first variant)......Page 817 Cursor list representation (revised variant)......Page 819 Merging the list and the sentinels......Page 823 Header as sentinel (empty list)......Page 825 23.5 SELECTIVE EXPORTS......Page 827 23.6 DEALING WITH ABNORMAL CASES......Page 828 The a priori scheme......Page 829 Obstacles to the a priori scheme......Page 830 The a posteriori scheme......Page 831 The role of an exception mechanism......Page 832 23.7 CLASS EVOLUTION: THE OBSOLETE CLAUSE......Page 833 23.8 DOCUMENTING A CLASS AND A SYSTEM......Page 834 Documentation principle......Page 835 A system architecture diagram......Page 836 23.10 BIBLIOGRAPHICAL NOTES......Page 837 E23.7 Two-way lists......Page 838 E23.13 Self-documenting software......Page 839 24.1 HOW NOT TO USE INHERITANCE......Page 841 A proper model......Page 842 “Is-a” rule of inheritance......Page 843 To have and to be......Page 844 Another possible view......Page 845 Object and subobject......Page 846 The polymorphism rule......Page 848 24.3 AN APPLICATION: THE HANDLE TECHNIQUE......Page 849 Platform adaptation through inheritance......Page 850 Platform adaptation through a handle......Page 851 Taxomania rule......Page 852 Inheritance rule......Page 854 Wrong uses......Page 855 Classification of the valid categories of inherita.........Page 856 Definition: subtype inheritance......Page 857 Definition: extension inheritance......Page 858 Variation inheritance......Page 860 Definition: functional and type variation inherita.........Page 861 Definition: uneffecting inheritance......Page 862 Definition: structure inheritance......Page 863 Definition: facility inheritance......Page 864 24.6 ONE MECHANISM, OR MORE?......Page 865 Defining a subtype......Page 867 Enforcing the subtype view......Page 868 The need for descendant hiding......Page 869 A circle and its center......Page 870 Applications of descendant hiding......Page 871 Taxonomies and their limit
62915-4
The definitive reference on the most important new technology in software!
“While the original version of OOSC is a classic, OOSC 2/E is destined to overshadow it and all other general introductions . . . literally an epic work.” —James C. McKim, Jr., Hartford Graduate Center
“Compelling. Extremely well-written and literate . . . I recaptured that same sense of intellectual excitement I felt reading the first edition for the first time.” —Paul Dubois, Lawrence Livermore National Laboratory, Editor, Scientific Programming Dept., Computers in Physics
“The definitive tome on Object-Orientation . . . the finest piece of writing and thinking about this vast subject . . . Bertrand has a lot to say of great importance and says it well in this significantly revised book.” —Richard Wiener, University of Colorado, Colorado Springs, Editor, Journal for Object-Oriented Programming
A whole generation was introduced to object technology through the first edition of Bertrand Meyer's OOSC. This long-awaited new edition retains the qualities of clarity, practicality and scholarship that made the first an instant best-seller. It has been thoroughly revised and considerably expanded. No other book on the market provides such a breadth and depth of coverage on the most important technology in software development.
SOME OF THE NEW TOPICS COVERED IN DEPTH BY THIS SECOND EDITION:
- Concurrency, distribution, client-server and the Internet.
- Object-oriented databases, persistence, schema evolution.
- Design by contract: how to build software that works the first time around.
- A study of fundamental design patterns.
- How to find the classes and many others topics of object-oriented methodology.
- How to use inheritance well and detect misuses.
- Abstract data types: the theory behind object technology.
- Typing: role, issues and solutions.
- More than 400 references to books, articles, Web pages, newsgroups; glossary of object technology.
- And many new developments on the topics of the first edition: reusability, modularity, software quality, O-O languages, inheritance techniques, genericity, memory management, etc.