Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

The Object-Oriented Thought Process
Nội dung xem thử
Mô tả chi tiết
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
Cape Town • Sydney • Tokyo • Singapore • Mexico City
The Object-Oriented Thought Process, Fourth Edition
Copyright © 2013 by Pearson Education, Inc.
All rights reserved. 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 information
contained herein.
ISBN-13: 978-0-321-86127-6
ISBN-10: 0-321-86127-2
Library of Congress Cataloging-in-Publication data is on file.
First Printing March 2013
Acquisitions Editor
Mark Taber Development Editor
Songlin Qiu Managing Editor
Sandra Schroeder Project Editor
Seth Kerney Copy Editor
Barbara Hacha Indexer
Brad Herriman
Proofreader
Sarah Kearns Technical Reviewer
Jon Upchurch Editorial Assistant
Vanessa Evans Interior Designer
Gary Adair Cover Designer
Chuti Prasertsith Compositor
Bronkella Publishing LLC
Trademarks
All 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 mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and
as accurate as possible, but no warranty or fitness is implied.
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 book.
Bulk Sales
Pearson offers excellent discounts on this book when ordered
in quantity for bulk purchases or special sales. For more
information, please contact U.S. Corporate and Government
Sales
1-800-382-3419
For sales outside of the U.S., please contact International
Sales
Developer’s Library
ESSENTIAL REFERENCES FOR PROGRAMMING PROFESSIONALS
Developer’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 programmers.
Key titles include some of the best, most widely acclaimed
books within their topic areas: PHP & MySQL Web
Development
Luke Welling & Laura Thomson
ISBN 978-0-672-32916-6
MySQL
Paul DuBois
ISBN-13: 978-0-672-32938-8
Linux Kernel Development
Robert Love
ISBN-13: 978-0-672-32946-3
Python Essential Reference
David Beazley
ISBN-13: 978-0-672-32978-4
Programming in Objective-C
Stephen Kochan
ISBN-13: 978-0-672-32756-8
C++ Primer Plus
Stephen Prata
ISBN-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 safari.informit.com
Developer’s Library
informit.com/devlibrary
Contents at a Glance
Introduction
1 Introduction to Object-Oriented Concepts
2 How to Think in Terms of Objects
3 Advanced Object-Oriented Concepts
4 The Anatomy of a Class
5 Class Design Guidelines
6 Designing with Objects
7 Mastering Inheritance and Composition
8 Frameworks and Reuse: Designing with Interfaces and
Abstract Classes
9 Building Objects and Object-Oriented Design
10 Creating Object Models
11 Objects and Portable Data: XML and JSON
12 Persistent Objects: Serialization, Marshaling, and
Relational Databases
13 Objects in Web Services, Mobile Apps, and Hybrids
14 Objects and Client/Server Applications
15 Design Patterns
Index
Table of Contents
Introduction
This Book’s Scope
What’s New in the Fourth Edition
The Intended Audience
The Book’s Approach
This Book’s Conventions
Source Code Used in This Book
1 Introduction to Object-Oriented Concepts
The Fundamental Concepts
Objects and Legacy Systems
Procedural Versus OO Programming
Moving from Procedural to Object-Oriented Development
Procedural Programming
OO Programming
What Exactly Is an Object?
Object Data
Object Behaviors
What Exactly Is a Class?
Creating Objects
Attributes
Methods
Messages
Using Class Diagrams as a Visual Tool
Encapsulation and Data Hiding
Interfaces
Implementations
A Real-World Example of the
Interface/Implementation Paradigm
A Model of the Interface/Implementation Paradigm
Inheritance
Superclasses and Subclasses
Abstraction
Is-a Relationships
Polymorphism
Composition
Abstraction
Has-a Relationships
Conclusion
Example Code Used in This Chapter
The TestPerson Example: C# .NET
The TestShape Example: C# .NET
2 How to Think in Terms of Objects
Knowing the Difference Between the Interface and the
Implementation
The Interface
The Implementation
An Interface/Implementation Example
Using Abstract Thinking When Designing Interfaces
Providing the Absolute Minimal User Interface Possible
Determining the Users
Object Behavior
Environmental Constraints
Identifying the Public Interfaces
Identifying the Implementation
Conclusion
References
3 Advanced Object-Oriented Concepts
Constructors
When Is a Constructor Called?
What’s Inside a Constructor?
The Default Constructor
Using Multiple Constructors
The Design of Constructors
Error Handling
Ignoring the Problem
Checking for Problems and Aborting the Application
Checking for Problems and Attempting to Recover
Throwing an Exception
The Importance of Scope
Local Attributes
Object Attributes
Class Attributes
Operator Overloading
Multiple Inheritance
Object Operations
Conclusion
References
Example Code Used in This Chapter
The TestNumber Example: C# .NET
4 The Anatomy of a Class
The Name of the Class
Comments
Attributes
Constructors
Accessors
Public Interface Methods
Private Implementation Methods
Conclusion
References
Example Code Used in This Chapter
The TestCab Example: C# .NET
5 Class Design Guidelines
Modeling Real-World Systems
Identifying the Public Interfaces
The Minimum Public Interface
Hiding the Implementation
Designing Robust Constructors (and Perhaps Destructors)
Designing Error Handling into a Class