Sample Pages
Download the sample pages (includes Chapter 2)
Table of Contents
Introduction 1
Chapter 1 Introduction to Object-Oriented Concepts 5
The Fundamental Concepts 5
Objects and Legacy Systems 6
Procedural Versus OO Programming 7
Moving from Procedural to Object-Oriented Development 11
Procedural Programming 11
OO Programming 11
What Exactly Is an Object? 12
Object Data 12
Object Behaviors 13
What Exactly Is a Class? 16
Creating Objects 17
Attributes 18
Methods 19
Messages 19
Using Class Diagrams as a Visual Tool 19
Encapsulation and Data Hiding 20
Interfaces 20
Implementations 21
A Real-World Example of the Interface/Implementation Paradigm 21
A Model of the Interface/Implementation Paradigm 22
Inheritance 23
Superclasses and Subclasses 24
Abstraction 25
Is-a Relationships 26
Polymorphism 27
Composition 30
Abstraction 30
Has-a Relationships 31
Conclusion 31
Chapter 2 How to Think in Terms of Objects 33
Knowing the Difference Between the Interface and the
Implementation 34
The Interface 36
The Implementation 36
An Interface/Implementation Example 36
Using Abstract Thinking When Designing Interfaces 41
Providing the Absolute Minimal User Interface Possible 42
Determining the Users 43
Object Behavior 44
Environmental Constraints 44
Identifying the Public Interfaces 44
Identifying the Implementation 45
Conclusion 46
References 46
Chapter 3 More Object-Oriented Concepts 47
Constructors 47
When Is a Constructor Called? 48
What’s Inside a Constructor? 48
The Default Constructor 48
Using Multiple Constructors 49
The Design of Constructors 53
Error Handling 54
Ignoring the Problem 54
Checking for Problems and Aborting the Application 54
Checking for Problems and Attempting to Recover 54
Throwing an Exception 55
The Importance of Scope 57
Local Attributes 58
Object Attributes 59
Class Attributes 61
Operator Overloading 62
Multiple Inheritance 63
Object Operations 63
Conclusion 65
References 65
Chapter 4 The Anatomy of a Class 67
The Name of the Class 67
Comments 69
Attributes 69
Constructors 71
Accessors 73
Public Interface Methods 75
Private Implementation Methods 76
Conclusion 76
References 76
Chapter 5 Class Design Guidelines 77
Modeling Real-World Systems 77
Identifying the Public Interfaces 78
The Minimum Public Interface 78
Hiding the Implementation 79
Designing Robust Constructors (and Perhaps Destructors) 80
Designing Error Handling into a Class 81
Documenting a Class and Using Comments 81
Building Objects with the Intent to Cooperate 82
Designing with Reuse in Mind 82
Designing with Extensibility in Mind 83
Making Names Descriptive 83
Abstracting Out Nonportable Code 84
Providing a Way to Copy and Compare Objects 84
Keeping the Scope as Small as Possible 84
Designing with Maintainability in Mind 86
Using Iteration in the Development Process 86
Testing the Interface 86
Using Object Persistence 88
Serializing and Marshaling Objects 89
Conclusion 90
References 90
Chapter 6 Designing with Objects 91
Design Guidelines 91
Performing the Proper Analysis 95
Developing a Statement of Work 95
Gathering the Requirements 95
Developing a System Prototype 96
Identifying the Classes 96
Determining the Responsibilities of Each Class 96
Determining How the Classes Collaborate with Each Other 96
Creating a Class Model to Describe the System 96
Prototyping the User Interface in Code 97
Object Wrappers 97
Structured Code 98
Wrapping Structured Code 99
Wrapping Nonportable Code 101
Wrapping Existing Classes 101
Conclusion 102
References 103
Chapter 7 Mastering Inheritance and Composition 105
Reusing Objects 105
Inheritance 106
Generalization and Specialization 109
Design Decisions 110
Composition 112
Representing Composition with UML 113
Why Encapsulation Is Fundamental to OO 115
How Inheritance Weakens Encapsulation 115
A Detailed Example of Polymorphism 117
Object Responsibility 118
Abstract Classes, Virtual Methods, and Protocols 121
Conclusion 123
References 123
Chapter 8 Frameworks and Reuse: Designing with Interfaces and Abstract Classes 125
Code: To Reuse or Not to Reuse? 125
What Is a Framework? 126
What Is a Contract? 128
Abstract Classes 128
Interfaces 131
Tying It All Together 133
The Compiler Proof 135
Making a Contract 136
System Plug-in Points 138
An E-Business Example 139
An E-Business Problem 139
The Non-Reuse Approach 139
An E-Business Solution 141
The UML Object Model 142
Conclusion 146
References 146
Chapter 9 Building Objects and Object-Oriented Design 147
Composition Relationships 148
Building in Phases 149
Types of Composition 151
Aggregations 151
Associations 152
Using Associations and Aggregations Together 153
Avoiding Dependencies 154
Cardinality 155
Multiple Object Associations 157
Optional Associations 158
Tying It All Together: An Example 159
Conclusion 160
References 160
Chapter 10 Design Patterns 161
Why Design Patterns? 162
Smalltalk’s Model/View/Controller 163
Types of Design Patterns 164
Creational Patterns 165
Structural Patterns 169
Behavioral Patterns 171
Antipatterns 173
Conclusion 174
References 174
Chapter 11 Avoiding Dependencies and Highly Coupled Classes 175
Composition versus Inheritance and Dependency Injection 177
1) Inheritance 177
2) Composition 179
Dependency Injection 182
Conclusion 185
References 185
Chapter 12 The SOLID Principles of Object-Oriented Design 187
The SOLID Principles of Object-Oriented Design 188
1) SRP: Single Responsibility Principle 188
2) OCP: Open/Close Principle 192
3) LSP: Liskov Substitution Principle 194
4) IPS: Interface Segregation Principle 197
5) DIP: Dependency Inversion Principle 198
Conclusion 204
References 204
9780135181966 TOC 3/12/2019