Example: marketing

The Object-Oriented Thought Process

The Object-Oriented Thought ProcessFourth s LibraryDeveloper s Library books are designed to provide practicing programmers with unique, high-quality references and tutorials on the programming languages and technologies they use in their daily work. All books in the Developer s Library are written by expert technology practitioners who are especially skilled at organizing and presenting information in a way that s useful for other titles include some of the best, most widely acclaimed books within their topic areas:PHP & MySQL Web DevelopmentLuke Welling & Laura ThomsonISBN 978-0-672-32916-6 MySQLPaul DuBoisISBN-13: 978-0-672-32938-8 Linux Kernel DevelopmentRobert LoveISBN-13: 978-0-672-32946-3 Python Essential ReferenceDavid BeazleyISBN-13: 978-0-672-32978-4 Programming in Objective-CStephen KochanISBN-13: 978-0-672-32756-8C++ Primer PlusStephen PrataISBN-13: 978-0321-77640-2 Developer s Library books are available at most retail and online bookstores, as well as by subscription from Safari Books Online at REFERENCES FOR PROGRAMMING PROFESSIONALSD eveloper s LibraryThe Object-Oriented Thought ProcessFourth EditionMatt WeisfeldUpper Saddle River, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCape Town Sydney Tokyo Singapore Mexico CityThe Object-Oriented Thought Process , Fourth EditionCopyright 2013 by Pearson Education, rights reserved.

The Object-Oriented Thought Process Fourth Edition Matt Weisfeld Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid

Tags:

  Process, Thought, Object, Oriented, The object oriented thought process

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of The Object-Oriented Thought Process

1 The Object-Oriented Thought ProcessFourth s LibraryDeveloper s Library books are designed to provide practicing programmers with unique, high-quality references and tutorials on the programming languages and technologies they use in their daily work. All books in the Developer s Library are written by expert technology practitioners who are especially skilled at organizing and presenting information in a way that s useful for other titles include some of the best, most widely acclaimed books within their topic areas:PHP & MySQL Web DevelopmentLuke Welling & Laura ThomsonISBN 978-0-672-32916-6 MySQLPaul DuBoisISBN-13: 978-0-672-32938-8 Linux Kernel DevelopmentRobert LoveISBN-13: 978-0-672-32946-3 Python Essential ReferenceDavid BeazleyISBN-13: 978-0-672-32978-4 Programming in Objective-CStephen KochanISBN-13: 978-0-672-32756-8C++ Primer PlusStephen PrataISBN-13: 978-0321-77640-2 Developer s Library books are available at most retail and online bookstores, as well as by subscription from Safari Books Online at REFERENCES FOR PROGRAMMING PROFESSIONALSD eveloper s LibraryThe Object-Oriented Thought ProcessFourth EditionMatt WeisfeldUpper Saddle River, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCape Town Sydney Tokyo Singapore Mexico CityThe Object-Oriented Thought Process , Fourth EditionCopyright 2013 by Pearson Education, rights reserved.

2 No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the informa-tion contained : 978-0-321-86127-6 ISBN-10: 0-321-86127-2 Library of Congress Cataloging-in-Publication data is on Printing March 2013 TrademarksAll terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Pearson cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied.

3 The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this SalesPearson offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please Corporate and Government sales outside of the , please contactInternational EditorMark TaberDevelopment EditorSonglin QiuManaging EditorSandra SchroederProject EditorSeth KerneyCopy EditorBarbara HachaIndexerBrad HerrimanProofreaderSarah KearnsTechnical ReviewerJon UpchurchEditorial AssistantVanessa EvansInterior DesignerGary AdairCover DesignerChuti PrasertsithCompositorBronkella Publishing LLCC ontents at a Glance Introduction 1 1 Introduction to Object-Oriented Concepts 5 2 How to Think in Terms of Objects 37 3 Advanced Object-Oriented Concepts 53 4 The Anatomy of a Class 75 5 Class Design Guidelines 87 6 Designing with Objects 105 7 Mastering Inheritance and Composition 119 8 Frameworks and Reuse.

4 Designing with Interfaces and Abstract Classes 141 9 Building Objects and Object-Oriented Design 167 10 Creating object Models 183 11 Objects and Portable Data: XML and JSON 197 12 Persistent Objects: Serialization, Marshaling, and Relational Databases 219 13 Objects in Web Services, Mobile Apps, and Hybrids 237 14 Objects and Client/Server Applications 263 15 Design Patterns 277 Index 297 Table of Contents Introduction 1 This Book s Scope 1 What s New in the Fourth Edition 2 The Intended Audience 3 The Book s Approach 3 This Book s Conventions 4 Source Code Used in This Book 4 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 11OO Programming 12 What Exactly Is an object ? 12 object Data 12 object Behaviors 13 What Exactly Is a Class?

5 17 Creating Objects 18 Attributes 19 Methods 20 Messages 20 Using Class Diagrams as a Visual Tool 20 Encapsulation and Data Hiding 21 Interfaces 21 Implementations 22A Real-World Example of the Interface/Implementation Paradigm 23A Model of the Interface/Implementation Paradigm 23 Inheritance 25 Superclasses and Subclasses 26 Abstraction 26Is-a Relationships 27viiContentsPolymorphism 28 Composition 31 Abstraction 32 Has-a Relationships 32 Conclusion 32 Example Code Used in This Chapter 33 The TestPerson Example: C# .NET 33 The TestShape Example: C# .NET 34 2 How to Think in Terms of Objects 37 Knowing the Difference Between the Interface and the Implementation 38 The Interface 40 The Implementation 40An Interface/Implementation Example 41 Using Abstract Thinking When Designing Interfaces 45 Providing the Absolute Minimal User Interface Possible 47 Determining the Users 48 object Behavior 49 Environmental Constraints 49 Identifying the Public Interfaces 49 Identifying the Implementation 50 Conclusion 51 References 51 3 Advanced Object-Oriented Concepts 53 Constructors 53 When Is a Constructor Called?

6 54 What s Inside a Constructor? 54 The Default Constructor 55 Using Multiple Constructors 55 The Design of Constructors 60 Error Handling 60 Ignoring the Problem 60 Checking for Problems and Aborting the Application 61 Checking for Problems and Attempting to Recover 61 Throwing an Exception 61viiiContentsThe Importance of Scope 64 Local Attributes 64 object Attributes 65 Class Attributes 67 Operator Overloading 69 Multiple Inheritance 70 object Operations 70 Conclusion 72 References 72 Example Code Used in This Chapter 72 The TestNumber Example: C# .NET 72 4 The Anatomy of a Class 75 The Name of the Class 75 Comments 77 Attributes 77 Constructors 79 Accessors 81 Public Interface Methods 83 Private Implementation Methods 84 Conclusion 84 References 85 Example Code Used in This Chapter 85 The TestCab Example: C# .NET 85 5 Class Design Guidelines 87 Modeling Real-World Systems 87 Identifying the Public Interfaces 88 The Minimum Public Interface 88 Hiding the Implementation 89 Designing Robust Constructors (and Perhaps Destructors) 90 Designing Error Handling into a Class 91 Documenting a Class and Using Comments 91 Building Objects with the Intent to Cooperate 92 Designing with Reuse in Mind 92ixContentsDesigning with Extensibility in Mind 93 Making Names Descriptive 93 Abstracting Out Nonportable Code 94 Providing a Way to Copy and Compare Objects 94 Keeping the Scope as Small as Possible 94A Class Should Be Responsible for Itself 96 Designing with Maintainability in Mind 97 Using Iteration in the Development Process 98 Testing the Interface 98 Using object Persistence 100 Serializing and Marshaling Objects 101 Conclusion 102 References 102 Example Code Used in This Chapter 102 The TestMath Example.

7 C# .NET 102 6 Designing with Objects 105 Design Guidelines 105 Performing the Proper Analysis 109 Developing a Statement of Work 109 Gathering the Requirements 109 Developing a Prototype of the User Interface 110 Identifying the Classes 110 Determining the Responsibilities of Each Class 110 Determining How the Classes Collaborate with Each Other 110 Creating a Class Model to Describe the System 111 Prototyping the User Interface 111 object Wrappers 111 Structured Code 112 Wrapping Structured Code 113 Wrapping Nonportable Code 115 Wrapping Existing Classes 116 Conclusion 117 References 117xContents 7 Mastering Inheritance and Composition 119 Reusing Objects 119 Inheritance 120 Generalization and Specialization 124 Design Decisions 124 Composition 126 Representing Composition with UML 127 Why Encapsulation Is Fundamental to OO 129 How Inheritance Weakens Encapsulation 130A Detailed Example

8 Of Polymorphism 132 object Responsibility 132 Abstract Classes, Virtual Methods, and Protocols 136 Conclusion 138 References 138 Example Code Used in This Chapter 138 8 Frameworks and Reuse: Designing with Interfaces and Abstract Classes 141 Code: To Reuse or Not to Reuse? 141 What Is a Framework? 142 What Is a Contract? 144 Abstract Classes 145 Interfaces 147 Tying It All Together 149 The Compiler Proof 152 Making a Contract 153 System Plug-in Points 155An E-Business Example 155An E-Business Problem 155 The Non-Reuse Approach 156An E-Business Solution 158 The UML object Model 158 Conclusion 163 References 163 Example Code Used in This Chapter 163 The TestShop Example: C# .NET 164xiContents 9 Building Objects and Object-Oriented Design 167 Composition Relationships 168 Building in Phases 169 Types of Composition 171 Aggregations 172 Associations 172 Using Associations and Aggregations Together 174 Avoiding Dependencies 174 Cardinality 175 Multiple object Associations 178 Optional Associations 178 Tying It All Together: An Example 179 Conclusion 181 References 181 10 Creating object Models 183 What Is UML?

9 183 The Structure of a Class Diagram 184 Attributes and Methods 186 Attributes 186 Methods 186 Access Designations 187 Inheritance 188 Interfaces 190 Composition 191 Aggregations 191 Associations 192 Cardinality 194 Conclusion 195 References 196 11 Objects and Portable Data: XML and JSON 197 Portable Data 197 The Extensible Markup Language (XML) 199 XML Versus HTML 199 XML and Object-Oriented Languages 200 Sharing Data Between Two Companies 202 Validating the Document with the Document Type Definition (DTD) 202xiiContentsIntegrating the DTD into the XML Document 204 Using Cascading Style Sheets 210 JavaScript object Notation (JSON) 212 Conclusion 217 References 217 12 Persistent Objects: Serialization, Marshaling, and Relational Databases 219 Persistent Objects Basics 219 Saving the object to a Flat File 221 Serializing a File 222 Implementation and Interface Revisited 224 What About the Methods?

10 225 Using XML in the Serialization Process 226 Writing to a Relational Database 228 Accessing a Relational Database 230 Conclusion 232 References 232 Example Code Used in This Chapter 233 The Person Class Example: C# .NET 233 13 Objects in Web Services, Mobile Apps, and Hybrids 237 Evolution of Distributed Computing 237 object -Based Scripting Languages 238A JavaScript Validation Example 241 Objects in a Web Page 244 JavaScript Objects 245 Web Page Controls 247 Sound Players 248 Movie Player 248 Flash 249 Distributed Objects and the Enterprise 249 The Common object Request Broker Architecture (CORBA) 251 Web Services Definition 254 Web Services Code 258 Representational State Transfer (ReST) 260xiiiContentsConclusion 261 References 261 14 Objects and Client/Server Applications 263 Client/Server Approaches 263 Proprietary Approach 264 Serialized object Code 264 Client Code 265 Server Code 267 Running the Proprietary Client/Server Example 268 Nonproprietary Approach 270 object Definition Code 271 Client Code 272 Server Code 273 Running the Nonproprietary Client/Server Example 275 Conclusion 276 References 276 Example Code Used in This Chapter 276 15 Design Patterns 277 Why Design Patterns?


Related search queries