07.12.2012 Views

Object-Oriented Programming With ANSI-C (pdf)

Object-Oriented Programming With ANSI-C (pdf)

Object-Oriented Programming With ANSI-C (pdf)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

viii __________________________________________________________________________ Contents<br />

4.8 Summary . . . . . . . . . . . . . . . . . . . . . . 40<br />

4.9 Is It or Has It? — Inheritance vs. Aggregates . . . . . . . . 42<br />

4.10 Multiple Inheritance . . . . . . . . . . . . . . . . . . 42<br />

4.11 Exercises . . . . . . . . . . . . . . . . . . . . . . 43<br />

5 <strong>Programming</strong> Savvy — Symbol Table . . . . . . . . . . . . . 45<br />

5.1 Scanning Identifiers . . . . . . . . . . . . . . . . . . 45<br />

5.2 Using Variables . . . . . . . . . . . . . . . . . . . . 45<br />

5.3 The Screener — Name . . . . . . . . . . . . . . . . . 47<br />

5.4 Superclass Implementation — Name . . . . . . . . . . . . 48<br />

5.5 Subclass Implementation — Var . . . . . . . . . . . . . . 50<br />

5.6 Assignment . . . . . . . . . . . . . . . . . . . . . 51<br />

5.7 Another Subclass — Constants . . . . . . . . . . . . . . 52<br />

5.8 Mathematical Functions — Math . . . . . . . . . . . . . 52<br />

5.9 Summary . . . . . . . . . . . . . . . . . . . . . . 55<br />

5.10 Exercises . . . . . . . . . . . . . . . . . . . . . . 55<br />

6 Class Hierarchy — Maintainability . . . . . . . . . . . . . . . 57<br />

6.1 Requirements . . . . . . . . . . . . . . . . . . . . . 57<br />

6.2 Metaclasses . . . . . . . . . . . . . . . . . . . . . 58<br />

6.3 Roots — <strong>Object</strong> and Class . . . . . . . . . . . . . . . . 59<br />

6.4 Subclassing — Any . . . . . . . . . . . . . . . . . . 60<br />

6.5 Implementation — <strong>Object</strong> . . . . . . . . . . . . . . . . 62<br />

6.6 Implementation — Class . . . . . . . . . . . . . . . . 63<br />

6.7 Initialization . . . . . . . . . . . . . . . . . . . . . 65<br />

6.8 Selectors . . . . . . . . . . . . . . . . . . . . . . 65<br />

6.9 Superclass Selectors . . . . . . . . . . . . . . . . . . 66<br />

6.10 A New Metaclass — PointClass . . . . . . . . . . . . . . 68<br />

6.11 Summary . . . . . . . . . . . . . . . . . . . . . . 70<br />

7 The ooc Preprocessor — Enforcing a Coding Standard . . . . . . 73<br />

7.1 Point Revisited . . . . . . . . . . . . . . . . . . . . 73<br />

7.2 Design . . . . . . . . . . . . . . . . . . . . . . . 78<br />

7.3 Preprocessing . . . . . . . . . . . . . . . . . . . . 79<br />

7.4 Implementation Strategy . . . . . . . . . . . . . . . . 80<br />

7.5 <strong>Object</strong> Revisited . . . . . . . . . . . . . . . . . . . . 82<br />

7.6 Discussion . . . . . . . . . . . . . . . . . . . . . . 84<br />

7.7 An Example — List, Queue, and Stack . . . . . . . . . . . 85<br />

7.8 Exercises . . . . . . . . . . . . . . . . . . . . . . 89<br />

8 Dynamic Type Checking — Defensive <strong>Programming</strong> . . . . . . . 91<br />

8.1 Technique . . . . . . . . . . . . . . . . . . . . . . 91<br />

8.2 An Example — list . . . . . . . . . . . . . . . . . . . 92<br />

8.3 Implementation . . . . . . . . . . . . . . . . . . . . 94<br />

8.4 Coding Standard . . . . . . . . . . . . . . . . . . . . 94<br />

8.5 Avoiding Recursion . . . . . . . . . . . . . . . . . . 98<br />

8.6 Summary . . . . . . . . . . . . . . . . . . . . . . 100<br />

8.7 Exercises . . . . . . . . . . . . . . . . . . . . . . 101

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!