The Object-Oriented Thought Process

Book Description

The Object-Oriented Thought Process

Third Edition

Matt Weisfeld

An introduction to object-oriented concepts for developers looking to master modern application practices.

Object-oriented programming (OOP) is the foundation of modern programming languages, including C++, Java, C#, and Visual Basic .NET. By designing with objects rather than treating the code and data as separate entities, OOP allows objects to fully utilize other objects’ services as well as inherit their functionality. OOP promotes code portability and reuse, but requires a shift in thinking to be fully understood. Before jumping into the world of object-oriented programming languages, you must first master The Object-Oriented Thought Process.

Written by a developer for developers who want to make the leap to object-oriented technologies as well as managers who simply want to understand what they are managing, The Object-Oriented Thought Process provides a solution-oriented approach to object-oriented programming. Readers will learn to understand object-oriented design with inheritance or composition, object aggregation and association, and the difference between interfaces and implementations. Readers will also become more efficient and better thinkers in terms of object-oriented development.

This revised edition focuses on interoperability across various technologies, primarily using XML as the communication mechanism. A more detailed focus is placed on how business objects operate over networks, including client/server architectures and web services.

“Programmers who aim to create high quality software–as all programmers should–must learn the varied subtleties of the familiar yet not so familiar beasts called objects and classes. Doing so entails careful study of books such as Matt Weisfeld’s The Object-Oriented Thought Process.”

–Bill McCarty, author of Java Distributed Objects, and Object-Oriented Design in Java

Matt Weisfeld is an associate professor in business and technology at Cuyahoga Community College in Cleveland, Ohio. He has more than 20 years of experience as a professional software developer, project manager, and corporate trainer using C++, Smalltalk, .NET, and Java. He holds a BS in systems analysis, an MS in computer science, and an MBA in project management. Weisfeld has published many articles in major computer trade magazines and professional journals.

Table of Contents

  1. Copyright
    1. Dedication
  2. Developer’s Library
  3. About the Author
  4. Acknowledgments
  5. We Want to Hear from You!
  6. Reader Services
  7. Introduction
    1. This Book’s Scope
    2. What’s New in the Third Edition
    3. The Intended Audience
    4. This Book’s Scope
    5. This Book’s Conventions
    6. Source Code Used in This Book
  8. 1. Introduction to Object-Oriented Concepts
    1. Procedural Versus OO Programming
    2. Moving from Procedural to Object-Oriented Development
      1. Procedural Programming
      2. OO Programming
    3. What Exactly Is an Object?
      1. Object Data
      2. Object Behaviors
    4. What Exactly Is a Class?
      1. Classes Are Object Templates
      2. Attributes
      3. Methods
      4. Messages
    5. Using UML to Model a Class Diagram
    6. Encapsulation and Data Hiding
      1. Interfaces
      2. Implementations
      3. A Real-World Example of the Interface/Implementation Paradigm
      4. A Model of the Interface/Implementation Paradigm
    7. Inheritance
      1. Superclasses and Subclasses
      2. Abstraction
      3. Is-a Relationships
    8. Polymorphism
    9. Composition
      1. Abstraction
      2. Has-a Relationships
    10. Conclusion
    11. Example Code Used in This Chapter
      1. The TestPerson Example: C# .NET
      2. The TestPerson Example: VB .NET
      3. The TestShape Example: C# .NET
      4. The TestShape Example: VB .NET
  9. 2. How to Think in Terms of Objects
    1. Knowing the Difference Between the Interface and the Implementation
      1. The Interface
      2. The Implementation
      3. An Interface/Implementation Example
    2. Using Abstract Thinking When Designing Interfaces
    3. Giving the User the Minimal Interface Possible
      1. Determining the Users
      2. Object Behavior
      3. Environmental Constraints
      4. Identifying the Public Interfaces
      5. Identifying the Implementation
    4. Conclusion
    5. References
  10. 3. Advanced Object-Oriented Concepts
    1. Constructors
      1. When Is a Constructor Called?
      2. What’s Inside a Constructor?
      3. The Default Constructor
      4. Using Multiple Constructors
        1. Overloading Methods
        2. Using UML to Model Classes
        3. How the Superclass Is Constructed
      5. The Design of Constructors
    2. Error Handling
      1. Ignoring the Problem
      2. Checking for Problems and Aborting the Application
      3. Checking for Problems and Attempting to Recover
      4. Throwing an Exception
    3. The Concept of Scope
      1. Local Attributes
      2. Object Attributes
      3. Class Attributes
    4. Operator Overloading
    5. Multiple Inheritance
    6. Object Operations
    7. Conclusion
    8. References
    9. Example Code Used in This Chapter
      1. The TestNumber Example: C# .NET
      2. The TestNumber Example: VB .NET
  11. 4. The Anatomy of a Class
    1. The Name of the Class
    3. Attributes
    4. Constructors
    5. Accessors
    6. Public Interface Methods
    7. Private Implementation Methods
    8. Conclusion
    9. References
    10. Example Code Used in This Chapter
      1. The TestCab Example: C# .NET
      2. The TestCab Example: VB .NET
  12. 5. Class Design Guidelines
    1. Modeling Real World Systems
    2. Identifying the Public Interfaces
      1. The Minimum Public Interface
      2. Hiding the Implementation
    3. Designing Robust Constructors (and Perhaps Destructors)
    4. Designing Error Handling into a Class
      1. Documenting a Class and Using Comments
      2. Building Objects with the Intent to Cooperate
    5. Designing with Reuse in Mind
    6. Designing with Extensibility in Mind
      1. Making Names Descriptive
      2. Abstracting Out Nonportable Code
      3. Providing a Way to Copy and Compare Objects
      4. Keeping the Scope as Small as Possible
      5. A Class Should Be Responsible for Itself
    7. Designing with Maintainability in Mind
      1. Using Iteration
      2. Testing the Interface
    8. Using Object Persistence
      1. Serializing and Marshaling Objects
    9. Conclusion
    10. References
    11. Example Code Used in This Chapter
      1. The TestMath Example: C# .NET
      2. The TestMath Example: VB .NET
  13. 6. Designing with Objects
    1. Design Guidelines
      1. Performing the Proper Analysis
      2. Developing a Statement of Work
      3. Gathering the Requirements
      4. Developing a Prototype of the User Interface
      5. Identifying the Classes
      6. Determining the Responsibilities of Each Class
      7. Determining How the Classes Collaborate with Each Other
      8. Creating a Class Model to Describe the System
    2. Case Study: A Blackjack Example
      1. Requirements Summary Statement
      2. Using CRC Cards
      3. Identifying the Blackjack Classes
      4. Identifying the Classes’ Responsibilities
        1. Card
        2. Deck
        3. Hand
        4. Dealer
        5. Player
        6. Bet
      5. UML Use-Cases: Identifying the Collaborations
      6. First Pass at CRC Cards
      7. UML Class Diagrams: The Object Model
      8. Prototyping the User Interface
    3. Conclusion
    4. References
  14. 7. Mastering Inheritance and Composition
    1. Reusing Objects
    2. Inheritance
      1. Generalization and Specialization
      2. Design Decisions
    3. Composition
      1. Representing Composition with UML
    4. Why Encapsulation Is Fundamental to OO
      1. How Inheritance Weakens Encapsulation
      2. A Detailed Example of Polymorphism
      3. Object Responsibility
    5. Conclusion
    6. References
    7. Example Code Used in This Chapter
      1. The TestShape Example: C# .NET
      2. The TestShape Example: VB .NET
  15. 8. Frameworks and Reuse: Designing with Interfaces and Abstract Classes
    1. Code: To Reuse or Not to Reuse?
    2. What Is a Framework?
    3. What Is a Contract?
      1. Abstract Classes
      2. Interfaces
      3. Tying It All Together
      4. The Compiler Proof
      5. Making a Contract
      6. System Plug-in-Points
    4. An E-Business Example
      1. An E-Business Problem
      2. The Non-Reuse Approach
      3. An E-Business Solution
      4. The UML Object Model
    5. Conclusion
    6. References
    7. Example Code Used in This Chapter
      1. The TestShape Example: C# .NET
      2. The TestShape Example: VB .NET
  16. 9. Building Objects
    1. Composition Relationships
    2. Building in Phases
    3. Types of Composition
      1. Aggregations
      2. Associations
      3. Using Associations and Aggregations Together
    4. Avoiding Dependencies
    5. Cardinality
      1. Multiple Object Associations
      2. Optional Associations
    6. Tying It All Together: An Example
    7. Conclusion
    8. References
  17. 10. Creating Object Models with UML
    1. What Is UML?
    2. The Structure of a Class Diagram
    3. Attributes and Methods
      1. Attributes
      2. Methods
    4. Access Designations
    5. Inheritance
    6. Interfaces
    7. Composition
      1. Aggregations
      2. Associations
    8. Cardinality
    9. Conclusion
    10. References
  18. 11. Objects and Portable Data: XML
    1. Portable Data
    2. The Extensible Markup Language (XML)
    3. XML Versus HTML
    4. XML and Object-Oriented Languages
    5. Sharing Data Between Two Companies
    6. Validating the Document with the Document Type Definition (DTD)
    7. Integrating the DTD into the XML Document
    8. Using Cascading Style Sheets
    9. Conclusion
    10. References
  19. 12. Persistent Objects: Serialization and Relational Databases
    1. Persistent Objects Basics
    2. Saving the Object to a Flat File
      1. Serializing a File
      2. Implementation and Interface Revisited
      3. What About the Methods?
    3. Using XML in the Serialization Process
    4. Writing to a Relational Database
      1. Accessing a Relational Database
    5. Loading the Driver
      1. Making the Connection
      2. The SQL Statements
    6. Conclusion
    7. References
    8. Example Code Used in This Chapter
      1. The Person Class Example: C# .NET
      2. The Person Class Example: VB .NET
  20. 13. Objects and the Internet
    1. Evolution of Distributed Computing
    2. Object-Based Scripting Languages
    3. A JavaScript Validation Example
    4. Objects in a Web Page
      1. JavaScript Objects
      2. Web Page Controls
      3. Sound Players
      4. Movie Players
      5. Flash
    5. Distributed Objects and the Enterprise
      1. The Common Object Request Broker Architecture (CORBA)
      2. Web Services Definition
      3. Web Services Code
      4. Invoice.cs
      5. Invoice.vb
    6. Conclusion
    7. References
  21. 14. Objects and Client/Server Applications
    1. Client/Server Approaches
    2. Proprietary Approach
      1. Serialized Object Code
      2. Client Code
      3. Server Code
      4. Running the Proprietary Client/Server Example
    3. Nonproprietary Approach
      1. Object Definition Code
      2. Client Code
      3. Server Code
      4. Running the Nonproprietary Client/Server Example
    4. Conclusion
    5. References
    6. Example Code Used in This Chapter
      1. The Client/Server Example—VB .NET: Object Definition Code
      2. The Client/Server Example—VB .NET: Client Code
      3. The Client/Server Example—VB .NET: Server Code
  22. 15. Design Patterns
    1. Why Design Patterns?
    2. Smalltalk’s Model/View/Controller
    3. Types of Design Patterns
      1. Creational Patterns
        1. The Singleton Design Pattern
      2. Structural Patterns
        1. The Adapter Design Pattern
      3. Behavioral Patterns
        1. The Iterator Design Pattern
    4. Antipatterns
    5. Conclusion
    6. References
    7. Example Code Used in This Chapter
      1. C# .NET
        1. Counter.cs
        2. Singleton.cs
        3. MailTool.cs
        4. Mailinterface.cs
        5. MyMail.cs
        6. Adapter.cs
        7. Iterator.cs
      2. VB .NET
        1. Counter.vb
        2. Singleton.vb
        3. MailTool.vb
        4. Mailinterface.vb
        5. MyMail.vb
        6. Adapter.vb
        7. Iterator.vb

Product Information

  • Title: The Object-Oriented Thought Process
  • Author(s): Matt Weisfeld
  • Release date: August 2008
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780768678666