Preface |
|
xi | |
Acknowledgements |
|
xv | |
Detailed Book Outline |
|
xvii | |
|
Section I Stable Type Design |
|
|
|
Chapter 1 Contractual Design and the Class Construct |
|
|
3 | (26) |
|
|
3 | (1) |
|
1.2 Explicit Design and Constraints |
|
|
4 | (12) |
|
1.2.1 Class (Type) Functionality |
|
|
5 | (4) |
|
|
9 | (3) |
|
1.2.3 Accessors and Mutators |
|
|
12 | (2) |
|
1.2.4 Utility and Public Methods |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
16 | (5) |
|
|
17 | (1) |
|
1.3.2 Published Assumptions |
|
|
18 | (2) |
|
|
20 | (1) |
|
1.4 Programming By Contract Example |
|
|
21 | (4) |
|
1.5 Contractual Expectations |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
Chapter 2 Ownership -- Abstracted but Tracked |
|
|
29 | (30) |
|
2.1 The Abstraction of Memory |
|
|
29 | (2) |
|
|
31 | (3) |
|
2.3 Ownership of Heap Objects |
|
|
34 | (10) |
|
|
37 | (1) |
|
2.3.2 Design Intervention |
|
|
38 | (2) |
|
|
40 | (4) |
|
|
44 | (2) |
|
|
46 | (6) |
|
2.5.1 C++ Explicit Deallocation |
|
|
47 | (1) |
|
|
47 | (3) |
|
|
50 | (2) |
|
2.6 Design: Storage Versus Computation |
|
|
52 | (3) |
|
|
55 | (1) |
|
2.7.1 Responsibility Driven Design Principle |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
59 | (30) |
|
|
59 | (3) |
|
|
62 | (7) |
|
3.2.1 Shallow versus Deep Copying |
|
|
62 | (1) |
|
3.2.2 C++ Copying of Internal Heap Memory |
|
|
63 | (6) |
|
|
69 | (4) |
|
3.3.1 C# Cloning to Avoid Aliasing |
|
|
71 | (2) |
|
|
73 | (3) |
|
3.5 Handle: C++ Smart Pointers |
|
|
76 | (6) |
|
|
78 | (2) |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
81 | (1) |
|
|
82 | (1) |
|
|
82 | (2) |
|
|
84 | (1) |
|
|
85 | (4) |
|
Section II Strategic Type Coupling |
|
|
|
|
89 | (30) |
|
4.1 Object-Oriented Relationships |
|
|
89 | (1) |
|
4.2 Containment (HOLDS-A) |
|
|
90 | (2) |
|
|
92 | (9) |
|
|
94 | (1) |
|
|
95 | (3) |
|
4.3.3 Postponed Instantiation |
|
|
98 | (1) |
|
4.3.4 Echoing an Interface |
|
|
99 | (2) |
|
4.4 Interfaces for Design Consistency |
|
|
101 | (2) |
|
4.5 Wrappers and Delegates |
|
|
103 | (3) |
|
|
106 | (8) |
|
4.6.1 Constructor Injection |
|
|
107 | (2) |
|
|
109 | (2) |
|
|
111 | (1) |
|
4.6.4 Dependency Injection Costs and Benefits |
|
|
112 | (2) |
|
|
114 | (1) |
|
|
115 | (1) |
|
|
116 | (1) |
|
|
117 | (2) |
|
|
119 | (34) |
|
5.1 Automate Type Checking |
|
|
119 | (5) |
|
|
124 | (6) |
|
|
125 | (1) |
|
|
126 | (1) |
|
5.2.3 Subtype Polymorphism |
|
|
127 | (1) |
|
|
128 | (1) |
|
5.2.5 Costs and Benefits of Polymorphism |
|
|
129 | (1) |
|
|
130 | (9) |
|
5.3.1 Whoami() Type Identification |
|
|
134 | (1) |
|
5.3.2 Keywords for Dynamic Binding |
|
|
134 | (5) |
|
5.4 Heterogeneous Collections |
|
|
139 | (3) |
|
5.5 Virtual Function Table |
|
|
142 | (1) |
|
|
143 | (4) |
|
|
147 | (2) |
|
|
149 | (1) |
|
|
149 | (1) |
|
|
149 | (2) |
|
|
151 | (2) |
|
Chapter 6 Inheritance versus Composition |
|
|
153 | (28) |
|
6.1 Constrained Inheritance |
|
|
153 | (7) |
|
6.1.1 When Only Composition Is Viable |
|
|
153 | (2) |
|
6.1.2 When Inheritance Leaks Memory: C++ Destructors |
|
|
155 | (3) |
|
6.1.3 Inconsistent Access: C++ Accessibility and Binding |
|
|
158 | (2) |
|
|
160 | (4) |
|
6.3 Class Design: Has-A or IS-A? |
|
|
164 | (2) |
|
6.4 Inheritance With and Without Composition |
|
|
166 | (6) |
|
6.5 Software Maintainability |
|
|
172 | (2) |
|
|
174 | (1) |
|
|
174 | (1) |
|
|
175 | (2) |
|
|
177 | (4) |
|
Section III Effective Type Reuse |
|
|
|
Chapter 7 Design Longevity |
|
|
181 | (30) |
|
|
181 | (1) |
|
|
182 | (6) |
|
7.2.1 Virtual Function Table |
|
|
187 | (1) |
|
|
188 | (5) |
|
7.4 Problematic Type Extension |
|
|
193 | (3) |
|
7.5 Multiple Inheritance and Its Simulation |
|
|
196 | (6) |
|
7.5.1 Design Difficulties |
|
|
198 | (1) |
|
7.5.2 Single Inheritance with Composition |
|
|
199 | (1) |
|
7.5.3 Simulation without Inheritance |
|
|
200 | (2) |
|
7.6 Class Hierarchies Cross-Products |
|
|
202 | (4) |
|
|
206 | (1) |
|
|
206 | (1) |
|
|
207 | (2) |
|
|
209 | (2) |
|
Chapter 8 Operator Overloading |
|
|
211 | (20) |
|
8.1 Operators Represent Functions |
|
|
211 | (2) |
|
8.2 Overloading Addition in C++ |
|
|
213 | (7) |
|
|
220 | (1) |
|
8.4 Operator Overloading in C# |
|
|
220 | (3) |
|
8.5 Operators Overloaded Only in C++ |
|
|
223 | (5) |
|
|
223 | (1) |
|
8.5.2 I/O via the Stream Operators |
|
|
224 | (2) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
228 | (1) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
230 | (1) |
|
APPENDIX A THE POINTER CONSTRUCT |
|
|
231 | (16) |
|
|
231 | (2) |
|
A.2 Dereferencing Pointers |
|
|
233 | (2) |
|
A.3 Inappropriate Use of Pointers |
|
|
235 | (1) |
|
A.4 Transient Versus Persistent Memory |
|
|
236 | (2) |
|
|
238 | (3) |
|
|
241 | (2) |
|
|
243 | (2) |
|
|
245 | (2) |
|
APPENDIX B DESIGN EXERCISES |
|
|
247 | (28) |
|
B.1 Contractual Class Design |
|
|
247 | (3) |
|
B.2 Ownership: C++ Class Memory Management |
|
|
250 | (4) |
|
|
254 | (7) |
|
|
261 | (7) |
|
|
268 | (7) |
|
APPENDIX C COMPARATIVE DESIGN EXERCISES |
|
|
275 | (26) |
|
C.1 Composition Versus Inheritance |
|
|
275 | (12) |
|
|
287 | (11) |
|
|
298 | (3) |
Glossary |
|
301 | (18) |
Bibliography |
|
319 | (2) |
Index |
|
321 | |