Object-Oriented Thought Process / Edition 4

Object-Oriented Thought Process / Edition 4

by Matt Weisfeld
ISBN-10:
0321861272
ISBN-13:
2900321861275
Pub. Date:
03/13/2013
Publisher:
Pearson Education
Object-Oriented Thought Process / Edition 4

Object-Oriented Thought Process / Edition 4

by Matt Weisfeld
$29.69 Current price is , Original price is $44.99. You
$44.99 
  • SHIP THIS ITEM
    This Item is Not Available
  • PICK UP IN STORE
    Check Availability at Nearby Stores
  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.

This Item is Not Available


Overview

The Object-Oriented Thought Process, Second Edition will lay the foundation in object-oriented concepts and then explain how various object technologies are used. Author Matt Weisfeld introduces object-oriented concepts, then covers abstraction, public and private classes, reusing code, and devloping frameworks. Later chapters cover building objects that work with XML, databases, and distributed systems (including EJBs, .NET, Web Services and more).Throughout the book Matt uses UML, the standard language for modeling objects, to provide illustration and examples of each concept.


Product Details

ISBN-13: 2900321861275
Publisher: Pearson Education
Publication date: 03/13/2013
Series: Developer's Library
Edition description: Older Edition
Pages: 336
Product dimensions: 6.90(w) x 8.90(h) x 0.90(d)

About the Author

Matt Weisfeld is a college professor, software developer, and author based in Cleveland, Ohio. Prior to teaching college full time, he spent 20 years in the information technology industry as a software developer, entrepreneur, and adjunct professor. Weisfeld holds an MS in computer science and an MBA. Besides several editions of The Object-Oriented Thought Process, Matt has authored two other software development books and published many articles in magazines and journals, such as informit.com, developer.com, Dr. Dobb’s Journal, The C/C++ Users Journal, Software Development Magazine, Java Report, and the international journal Project Management.

Read an Excerpt

IntroductionIntroductionThis Book's Scope

As the title indicates, this book is about the object-oriented (OO) thought process. Obviously, choosing the theme and title of the book are important decisions; however, these decisions were not all that simple. Numerous books deal with various levels of object orientation. Several popular books deal with topics including OO analysis, OO design, OO programming, design patterns, OO data (

However, while pouring over all of these books, many people forget that all of these topics are built on a single foundation: how you think in OO ways. It is unfortunate, but software professionals often dive into these books without taking the appropriate time and effort to really understand the concepts behind the content.

I contend that learning OO concepts is not accomplished by learning a specific development method or a set of tools. Doing things in an OO manner is, simply put, a way of thinking. This book is all about the OO thought process.

Separating the methods and tools from the OO thought process is not easy. Many people are introduced to OO concepts via one of these methods or tools. For example, years ago, most C programmers were first introduced to object orientation by migrating directly to C++—before they were even remotely exposed to OO concepts. Other software professionals were first introduced to object orientation by presentations that included object models using UML—again, before they were even exposed directly to OO concepts. It is not unusual to find that programming books and courses defer OO concepts until later in the learning process.

It is important to understand the significantdifference between learning OO concepts and using the methods and tools that support the paradigm. This came into focus for me before I worked on the first edition of this book when I read articles such as Craig Larman's "What the UML Is—and Isn't," In this article he states,

Unfortunately, in the context of software engineering and the UML diagramming language, acquiring the skills to read and write UML notation seems to sometimes be equated with skill in object-oriented analysis and design. Of course, this is not so, and the latter is much more important than the former. Therefore, I recommend seeking education and educational materials in which intellectual skill in object-oriented analysis and design is paramount rather than UML notation or the use of a case tool.

Although learning a modeling language is an important step, it is much more important to learn OO skills first. Learning UML before OO concepts is similar to learning how to read an electrical diagram without first knowing anything about electricity.

The same problem occurs with programming languages. As stated earlier, many C programmers moved into the realm of object orientation by migrating to C++ before being directly exposed to OO concepts. This would always come out in an interview. Many times developers who claim to be C++ programmers are simply C programmers using C++ compilers. Even now, with languages such as C# .NET, VB .NET, and Java well established, a few key questions in a job interview can quickly uncover a lack of OO understanding.

Early versions of Visual Basic are not OO. C is not OO, and C++ was developed to be backward compatible with C. Because of this, it is quite possible to use a C++ compiler (writing only C syntax) while forsaking all of C++'s OO features. Even worse, a programmer can use just enough OO features to make a program incomprehensible to OO and non-OO programmers alike.

Thus, it is of vital importance that while you're on the road to OO development, you first learn the fundamental OO concepts. Resist the temptation to jump directly into a programming language (such as VB .NET, C++, C# .NET or Java) or a modeling language (such as UML), and take the time to learn the object-oriented thought process.

In my first class in Smalltalk in the late 1980s, the instructor told the class that the new OO paradigm was a totally new way of thinking (despite the fact that it has been around since the 60s). He went on to say that although all of us were most likely very good programmers, about 10%–20% of us would never really grasp the OO way of doing things. If this statement is indeed true, it is most likely because some people never really take the time to make the paradigm shift and learn the underlying OO concepts.What's New in the Third Edition

As stated often in this introduction, my vision for the first edition was primarily a conceptual book. Although I still adhere to this goal for the second and third editions, I have included several application topics that fit well with object-oriented concepts. For the third edition I expand on many of the topics of the second edition and well as include totally new chapters. These revised and updated concepts

  • Object persistence and serialization.

  • Adding properties to attributes.

  • Client/Server technologies.

  • Expanded code examples in Java, C# .NET and VB .NET.

The chapters that cover these topics are still conceptual in nature; however, many of the chapters include Java code that shows how these concepts are implemented. In this third edition, a code appendix is included that presents the chapter's examples in C# .NET and Visual Basic .NET.The Intended Audience

This book is a general introduction to fundamental OO concepts with code examples to reinforce the concepts. One of the most difficult juggling acts was to keep the material conceptual while still providing a solid, technical code base. The goal of this book is to allow a reader to understand the concepts and technology without having a compiler at hand. However, if you do have a compiler available, then there is code to be investigated.

The intended audience includes business managers, designers, developers, programmers, project managers, and anyone who wants to gain a general understanding of what object orientation is all about. Reading this book should provide a strong foundation for moving to other books covering more advanced OO topics.

Of these more advanced books, one of my favorites remains Object-Oriented Design in Java by Stephen Gilbert and Bill McCarty. I really like the approach of the book, and have used it as a textbook in classes I have taught on OO concepts. I cite Object-Oriented Design in Java often throughout this book, and I recommend that you graduate to it after you complete this one.

Other books that I have found very helpful include Effective C++ by Scott Meyers, Classical and Object-Oriented Software Engineering by Stephen R. Schach, Thinking in C++ by Bruce Eckel, UML Distilled by Martin Flower, and Java Design by Peter Coad and Mark Mayfield.

The conceptual nature of this book provides a unique perspective in regards to other computer technology books. While books that focus on specific technologies, such as programming languages, struggle with the pace of change, this book has the luxury of presenting established concepts that, while certainly being fine-tuned, do not experience radical changes. With this in mind, many of the books that were referenced several years ago, are still referenced because the concepts are still fundamentally the same.This Book's Scope

It should be obvious by now that I am a firm believer in becoming comfortable with the object-oriented thought process before jumping into a programming language or modeling language. This book is filled with examples of code and UML diagrams; however, you do not need to know a specific programming language or UML to read it. After all I have said about learning the concepts first, why is there so much Java, C# .NET, and VB .NET code and so many UML diagrams? First, they are all great for illustrating OO concepts. Second, both are vital to the OO process and should be addressed at an introductory level. The key is not to focus on Java, C# .NET, and VB .NET or UML, but to use them as aids in the understanding of the underlying concepts.

The Java, C# .NET and VB .NET examples in the book illustrate concepts such as loops and functions. However, understanding the code itself is not a prerequisite for understanding the concepts; it might be helpful to have a book at hand that covers specific languages syntax if you want to get more detailed.

I cannot state too strongly that this book does not teach Java, C# .NET, and VB .NET or UML, all of which can command volumes unto themselves. It is my hope that this book will whet your appetite for other OO topics, such as OO analysis, object-oriented design, and OO programming.This Book's Conventions

The following conventions are used in this book:

  • Code lines, commands, statements, and any other code-related terms appear in a monospace typeface.

  • Placeholders that stand for what you should actually type appear in italic monospace. Text that you should type appears in bold monospace.

  • Throughout the book, there are special sidebar elements, such as

***

Note - A Note presents interesting information related to the discussion—a little more insight or a pointer to some new technique.

***
***

Tip - A Tip offers advice or shows you an easier way of doing something.

***
***

Caution - A Caution alerts you to a possible problem and gives you advice on how to avoid it.

***
Source Code Used in This Book

You can download all the source code and examples discussed within this book from the publisher's website.

© Copyright Pearson Education. All rights reserved.

Table of Contents

Foreword1
Introduction3
This Book's Scope3
The Intended Audience4
This Book's Scope5
References and Suggested Reading5
1Introduction to Object-Oriented Concepts7
Procedural Versus O-O Programming8
What Makes O-O Different from Procedural Programming?11
Procedural Programming11
O-O Programming12
What Exactly Is an Object?12
Object Data12
Object Behaviors13
What Exactly Is a Class?16
Classes Are Object Templates17
Attributes18
Methods19
Messages19
Using UML to Model a Class Diagram20
Encapsulation20
Interfaces21
Implementations21
A Real-World Example of the Interface/Implementation Paradigm21
A Java Example of the Interface/Implementation Paradigm22
Inheritance23
Superclasses and Subclasses24
Abstraction25
Is-a Relationships26
Polymorphism27
Composition30
Has-a Relationships31
Conclusion31
2How to Think in Terms of Objects33
Knowing the Difference Between the Interface and the Implementation34
The Interface36
The Implementation37
An Interface/Implementation Example37
Using Abstract Thinking when Designing Interfaces41
Giving the User the Minimal Interface Possible43
Determining the Users44
Object Behavior45
Environmental Constraints45
Identifying the Public Interfaces45
Identifying the Implementation46
Conclusion47
References47
3Advanced Object-Oriented Concepts49
Constructors50
When Is a Constructor Called?50
What's Inside a Constructor?51
The Default Constructor51
Using Multiple Constructors52
The Design of Constructors56
Error Handling56
Ignoring the Problem56
Checking for Problems and Aborting the Application57
Checking for Problems and Attempting to Recover57
Throwing an Exception57
The Concept of Scope60
Local Attributes60
Object Attributes61
Class Attributes64
Operator Overloading65
Multiple Inheritance66
Object Operations67
Conclusion68
References68
4The Anatomy of a Class69
The Name of the Class70
Comments72
Attributes73
Constructors74
Accessors76
Public Interface Methods78
Private Implementation Methods79
Conclusion79
References79
5Class Design Guidelines81
Identifying the Public Interfaces83
Hiding the Implementation84
Designing Robust Constructors (and Perhaps Destructors)84
Designing Error Handling into a Class85
Documenting a Class and Using Comments86
Building Objects with the Intent to Cooperate86
Designing with Reuse in Mind87
Designing with Extensibility in Mind87
Making Names Descriptive87
Abstracting Out Non-portable Code88
Providing a Way to Copy and Compare Objects89
Keeping the Scope as Small as Possible89
A Class Should Be Responsible for Itself90
Serializing and Marshalling Objects91
Designing with Maintainability in Mind92
Using Object Persistence92
Using Iteration93
Testing the Interface93
Conclusion95
References96
6Designing with Objects: The Software Development Process97
Design Guidelines98
Doing the Proper Analysis102
Developing a Statement of Work102
Gathering the Requirements102
Developing a Prototype of the User Interface103
Identifying the Classes103
Determining the Responsibilities of Each Class103
Determining How the Classes Interact with Each Other104
Creating a Class Model to Describe the System104
A Blackjack Example104
Using CRC Cards106
Identifying the Blackjack Classes107
Identifying the Classes' Responsibilities111
UML Use Cases: Identifying the Collaborations118
First Pass at CRC Cards122
UML Class Diagrams: The Object Model124
Prototyping the User Interface125
Conclusion126
References126
7Mastering Inheritance and Composition127
Inheritance129
Generalization and Specialization132
It's All in the Design133
Composition135
Representing Composition with UML136
Why Encapsulation Is Fundamental to O-O138
How Inheritance Weakens Encapsulation139
A Detailed Example of Polymorphism141
An Object Should Be Responsible for Itself142
Conclusion146
References146
8Frameworks and Reuse: Designing with Interfaces and Abstract Classes147
To Reuse or Not to Reuse?148
What Is a Framework?148
What Is a Contract?150
Abstract Classes151
Interfaces154
Making a Contract159
System Plug-in-Points161
An E-Business Example161
An E-Business Problem162
The Non-Reuse Approach163
An E-Business Solution165
The UML Object Model165
Conclusion171
References171
9Building Objects173
Composition Relationships175
Building in Phases176
Types of Composition178
Aggregations178
Associations180
Using Associations and Aggregations Together181
Avoiding Dependencies181
Cardinality183
Optional Associations186
Tying It All Together: An Example186
Conclusion188
References188
AAn Overview of UML Used in This Book189
What Is UML?190
The Structure of a Class Diagram190
Attributes and Methods192
Attributes192
Methods193
Access Designations193
Inheritance194
Interfaces195
Composition197
Aggregations197
Associations198
Cardinality200
Conclusion202
References203
BThe Evolution of Object-Oriented Languages205
O-O Languages206
Simula206
Smalltalk206
C++207
Java208
Supporting Object-Oriented Features208
Why Do New Languages Keep Coming Along?208
What Makes a State-of-the-Art Language?209
Conclusion211
References212
Index213

Preface

Introduction

Introduction

This Book's Scope

As the title indicates, this book is about the object-oriented (OO) thought process. Obviously, choosing the theme and title of the book are important decisions; however, these decisions were not all that simple. Numerous books deal with various levels of object orientation. Several popular books deal with topics including OO analysis, OO design, OO programming, design patterns, OO data (XML), the Unified Modeling Language (UML), OO Internet development, various OO programming languages, and many other topics related to OO development.

However, while pouring over all of these books, many people forget that all of these topics are built on a single foundation: how you think in OO ways. It is unfortunate, but software professionals often dive into these books without taking the appropriate time and effort to really understand the concepts behind the content.

I contend that learning OO concepts is not accomplished by learning a specific development method or a set of tools. Doing things in an OO manner is, simply put, a way of thinking. This book is all about the OO thought process.

Separating the methods and tools from the OO thought process is not easy. Many people are introduced to OO concepts via one of these methods or tools. For example, years ago, most C programmers were first introduced to object orientation by migrating directly to C++—before they were even remotely exposed to OO concepts. Other software professionals were first introduced to object orientation by presentations that included object models using UML—again, before they were even exposed directly to OO concepts. It is not unusual to find that programming books and courses defer OO concepts until later in the learning process.

It is important to understand the significant difference between learning OO concepts and using the methods and tools that support the paradigm. This came into focus for me before I worked on the first edition of this book when I read articles such as Craig Larman's "What the UML Is—and Isn't," In this article he states,

Unfortunately, in the context of software engineering and the UML diagramming language, acquiring the skills to read and write UML notation seems to sometimes be equated with skill in object-oriented analysis and design. Of course, this is not so, and the latter is much more important than the former. Therefore, I recommend seeking education and educational materials in which intellectual skill in object-oriented analysis and design is paramount rather than UML notation or the use of a case tool.

Although learning a modeling language is an important step, it is much more important to learn OO skills first. Learning UML before OO concepts is similar to learning how to read an electrical diagram without first knowing anything about electricity.

The same problem occurs with programming languages. As stated earlier, many C programmers moved into the realm of object orientation by migrating to C++ before being directly exposed to OO concepts. This would always come out in an interview. Many times developers who claim to be C++ programmers are simply C programmers using C++ compilers. Even now, with languages such as C# .NET, VB .NET, and Java well established, a few key questions in a job interview can quickly uncover a lack of OO understanding.

Early versions of Visual Basic are not OO. C is not OO, and C++ was developed to be backward compatible with C. Because of this, it is quite possible to use a C++ compiler (writing only C syntax) while forsaking all of C++'s OO features. Even worse, a programmer can use just enough OO features to make a program incomprehensible to OO and non-OO programmers alike.

Thus, it is of vital importance that while you're on the road to OO development, you first learn the fundamental OO concepts. Resist the temptation to jump directly into a programming language (such as VB .NET, C++, C# .NET or Java) or a modeling language (such as UML), and take the time to learn the object-oriented thought process.

In my first class in Smalltalk in the late 1980s, the instructor told the class that the new OO paradigm was a totally new way of thinking (despite the fact that it has been around since the 60s). He went on to say that although all of us were most likely very good programmers, about 10%–20% of us would never really grasp the OO way of doing things. If this statement is indeed true, it is most likely because some people never really take the time to make the paradigm shift and learn the underlying OO concepts.

What's New in the Third Edition

As stated often in this introduction, my vision for the first edition was primarily a conceptual book. Although I still adhere to this goal for the second and third editions, I have included several application topics that fit well with object-oriented concepts. For the third edition I expand on many of the topics of the second edition and well as include totally new chapters. These revised and updated concepts

  • XML is used for object communication.

  • Object persistence and serialization.

  • XML integrated into the languages object definition.

  • Adding properties to attributes.

  • XML-based Internet applications.

  • Client/Server technologies.

  • Expanded code examples in Java, C# .NET and VB .NET.

The chapters that cover these topics are still conceptual in nature; however, many of the chapters include Java code that shows how these concepts are implemented. In this third edition, a code appendix is included that presents the chapter's examples in C# .NET and Visual Basic .NET.

The Intended Audience

This book is a general introduction to fundamental OO concepts with code examples to reinforce the concepts. One of the most difficult juggling acts was to keep the material conceptual while still providing a solid, technical code base. The goal of this book is to allow a reader to understand the concepts and technology without having a compiler at hand. However, if you do have a compiler available, then there is code to be investigated.

The intended audience includes business managers, designers, developers, programmers, project managers, and anyone who wants to gain a general understanding of what object orientation is all about. Reading this book should provide a strong foundation for moving to other books covering more advanced OO topics.

Of these more advanced books, one of my favorites remains Object-Oriented Design in Java by Stephen Gilbert and Bill McCarty. I really like the approach of the book, and have used it as a textbook in classes I have taught on OO concepts. I cite Object-Oriented Design in Java often throughout this book, and I recommend that you graduate to it after you complete this one.

Other books that I have found very helpful include Effective C++ by Scott Meyers, Classical and Object-Oriented Software Engineering by Stephen R. Schach, Thinking in C++ by Bruce Eckel, UML Distilled by Martin Flower, and Java Design by Peter Coad and Mark Mayfield.

The conceptual nature of this book provides a unique perspective in regards to other computer technology books. While books that focus on specific technologies, such as programming languages, struggle with the pace of change, this book has the luxury of presenting established concepts that, while certainly being fine-tuned, do not experience radical changes. With this in mind, many of the books that were referenced several years ago, are still referenced because the concepts are still fundamentally the same.

This Book's Scope

It should be obvious by now that I am a firm believer in becoming comfortable with the object-oriented thought process before jumping into a programming language or modeling language. This book is filled with examples of code and UML diagrams; however, you do not need to know a specific programming language or UML to read it. After all I have said about learning the concepts first, why is there so much Java, C# .NET, and VB .NET code and so many UML diagrams? First, they are all great for illustrating OO concepts. Second, both are vital to the OO process and should be addressed at an introductory level. The key is not to focus on Java, C# .NET, and VB .NET or UML, but to use them as aids in the understanding of the underlying concepts.

The Java, C# .NET and VB .NET examples in the book illustrate concepts such as loops and functions. However, understanding the code itself is not a prerequisite for understanding the concepts; it might be helpful to have a book at hand that covers specific languages syntax if you want to get more detailed.

I cannot state too strongly that this book does not teach Java, C# .NET, and VB .NET or UML, all of which can command volumes unto themselves. It is my hope that this book will whet your appetite for other OO topics, such as OO analysis, object-oriented design, and OO programming.

This Book's Conventions

The following conventions are used in this book:

  • Code lines, commands, statements, and any other code-related terms appear in a monospace typeface.

  • Placeholders that stand for what you should actually type appear in italic monospace . Text that you should type appears in bold monospace .

  • Throughout the book, there are special sidebar elements, such as


Note - A Note presents interesting information related to the discussion—a little more insight or a pointer to some new technique.



Tip - A Tip offers advice or shows you an easier way of doing something.



Caution - A Caution alerts you to a possible problem and gives you advice on how to avoid it.


Source Code Used in This Book

You can download all the source code and examples discussed within this book from the publisher's website.

© Copyright Pearson Education. All rights reserved.

From the B&N Reads Blog

Customer Reviews