Beginning C# Object-Oriented Programming

Book description

Beginning C# Object-Oriented Programming brings you into the modern world of development as you master the fundamentals of programming with C# and learn to develop efficient, reusable, elegant code through the object-oriented programming (OOP) methodology. Take your skills out of the 20th century and into this one with Dan Clark's accessible, quick-paced guide to C# and OOP, completely updated for .NET 4.0 and C# 4.0.

As you develop techniques and best practices for coding in C#, one of the world's most popular contemporary languages, you'll experience modeling a "real world" application through a case study, allowing you to see how both C# and OOP (a methodology you can use with any number of languages) come together to make your code reusable, modern, and efficient.

Throug more than 30 fully hands-on activities, you'll discover how to transform a simple model of an application into a fully functional C# project, including designing the user interface, implementing the business logic, and integrating with a relational database for data storage. Along the way, you will explore the .NET Framework, the creation of a Windows-based user interface, a web-based user interface, and service-oriented programming, all using Microsoft industry leading Visual Studio 2010, C#, Silverlight, the Entity Framework, and more.

What you'll learn

  • Learn to use the Universal Modeling Language (UML) to quickly design an application correctly from the first time

  • Understand object-oriented programming principles and how they benefit your work in today's dual Web- and Windows-based world

  • Integrate OOP fundamentals when developing code in C#

  • Discover the .NET Framework and how it can help you create applications quickly and efficiently

  • Walk along as the author develops a complete Windows and Web-based application using the techniques and best practices covered inside

Who this book is for

  • If you're a beginning C# programmer who wants to gain a foundation in object-oriented programming along with the C# language basics, this book is for you.

  • Programmers transitioning from a procedural oriented programming model to an object oriented model will also find many practical suggestions and walkthroughs inside.

  • In particular, VB developers who want to transition to C# programming, but lack a firm grasp of object-oriented programming principles, will find this book an excellent starting point for your C# journey.

The book includes a primer in Appendix A that discusses some fundamental procedural programming concepts.

Table of Contents

  1. Overview of Object-Oriented Programming

  2. Designing OOP Solutions: Identifying the Class Structure

  3. Designing OOP Solutions: Modeling the Object Interaction

  4. Designing OOP Solutions: A Case Study

  5. Introducing the .NET Framework and Visual Studio

  6. Creating Classes

  7. Creating Class Hierarchies

  8. Implementing Object Collaboration

  9. Working with Collections

  10. Implementing the Data Access Layer

  11. Developing Windows Applications

  12. Developing Web Applications

  13. Developing and Consuming WCF Services

  14. Developing the OSO Application

  15. Wrapping Up

  16. Fundamental Programming Concepts

  17. Exception Handling in C#

  18. Installing the Required Software

Table of contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. Target Audience
    2. Organization of the Book
    3. Activities and Software Requirements
  6. 1. Overview of Object-Oriented Programming
    1. 1.1. The History of OOP
    2. 1.2. Why Use OOP?
    3. 1.3. The Characteristics of OOP
      1. 1.3.1. Objects
      2. 1.3.2. Abstraction
      3. 1.3.3. Encapsulation
      4. 1.3.4. Polymorphism
      5. 1.3.5. Inheritance
      6. 1.3.6. Aggregation
    4. 1.4. The History of C#
    5. 1.5. Summary
  7. 2. Designing OOP Solutions: Identifying the Class Structure
    1. 2.1. Goals of Software Design
    2. 2.2. Understanding the Unified Modeling Language
    3. 2.3. Developing a SRS
    4. 2.4. Introducing Use Cases
    5. 2.5. Understanding Class Diagrams
    6. 2.6. Modeling Object Relationships
      1. 2.6.1. Association
      2. 2.6.2. Inheritance
      3. 2.6.3. Aggregation
      4. 2.6.4. Association Classes
    7. 2.7. Summary
  8. 3. Designing OOP Solutions: Modeling the Object Interaction
    1. 3.1. Understanding Scenarios
    2. 3.2. Introducing Sequence Diagrams
    3. 3.3. Message Types
    4. 3.4. Recursive Messages
    5. 3.5. Message Iteration
    6. 3.6. Message Constraints
    7. 3.7. Message Branching
    8. 3.8. Understanding Activity Diagrams
      1. 3.8.1. Decision Points and Guard Conditions
      2. 3.8.2. Parallel Processing
      3. 3.8.3. Activity Ownership
    9. 3.9. Exploring GUI Design
      1. 3.9.1. GUI Activity Diagrams
      2. 3.9.2. Interface Prototyping
      3. 3.9.3. Interface Flow Diagrams
      4. 3.9.4. Application Prototyping
    10. 3.10. Summary
  9. 4. Designing OOP Solutions: A Case Study
    1. 4.1. Developing an OOP Solution
      1. 4.1.1. Creating the System Requirement Specification
      2. 4.1.2. Developing the Use Cases
      3. 4.1.3. Diagramming the Use Cases
      4. 4.1.4. Developing the Class Model
        1. 4.1.4.1. Identifying the Classes
        2. 4.1.4.2. Adding Attributes to the Classes
        3. 4.1.4.3. Identifying Class Associations
        4. 4.1.4.4. Modeling the Class Behaviors
        5. 4.1.4.5. Developing the User Interface Model Design
      5. 4.1.5. Avoiding Some Common OOP Design Pitfalls
    2. 4.2. Summary
  10. 5. Introducing the .NET Framework and Visual Studio
    1. 5.1. Introducing the .NET Framework
      1. 5.1.1. Goals of the .NET Framework
        1. 5.1.1.1. Support of Industry Standards
        2. 5.1.1.2. Extensibility
        3. 5.1.1.3. Unified Programming Models
        4. 5.1.1.4. Easier Deployment
        5. 5.1.1.5. Improved Memory Management
        6. 5.1.1.6. Improved Security Model
      2. 5.1.2. Components of the .NET Framework
        1. 5.1.2.1. Common Language Runtime
        2. 5.1.2.2. Framework Base Class Library
        3. 5.1.2.3. Data Classes
        4. 5.1.2.4. Windows Applications
        5. 5.1.2.5. Web Applications
        6. 5.1.2.6. Application Services
      3. 5.1.3. Working with the .NET Framework
        1. 5.1.3.1. Understanding Assemblies and Manifests
        2. 5.1.3.2. Referencing Assemblies and Namespaces
        3. 5.1.3.3. Compiling and Executing Managed Code
    2. 5.2. Using the Visual Studio Integrated Development Environment
      1. 5.2.1.
        1. 5.2.1.1. Customizing the IDE
        2. 5.2.1.2. Creating a New Project
        3. 5.2.1.3. Investigating the Solution Explorer and Class View
        4. 5.2.1.4. Exploring the Toolbox and Properties Window
        5. 5.2.1.5. Building and Executing the Assembly
        6. 5.2.1.6. Stepping Through Code
        7. 5.2.1.7. Setting Conditional Breakpoints
        8. 5.2.1.8. Locating and Fixing Build Errors
    3. 5.3. Summary
  11. 6. Creating Classes
    1. 6.1. Introducing Objects and Classes
    2. 6.2. Defining Classes
      1. 6.2.1. Creating Class Properties
      2. 6.2.2. Creating Class Methods
        1. 6.2.2.1. Defining the Employee Class
        2. 6.2.2.2. Testing the Employee Class
    3. 6.3. Using Constructors
    4. 6.4. Overloading Methods
      1. 6.4.1.
        1. 6.4.1.1. Creating and Overloading Class Constructors
        2. 6.4.1.2. Testing the Employee Class Constructors
        3. 6.4.1.3. Overloading a Class Method
        4. 6.4.1.4. Testing the Overloaded Update Method
    5. 6.5. Summary
  12. 7. Creating Class Hierarchies
    1. 7.1. Understanding Inheritance
      1. 7.1.1. Creating Base and Derived Classes
      2. 7.1.2. Creating a Sealed Class
      3. 7.1.3. Creating an Abstract Class
      4. 7.1.4. Using Access Modifiers in Base Classes
    2. 7.2. Overriding the Methods of a Base Class
      1. 7.2.1. Calling a Derived Class Method from a Base Class
      2. 7.2.2. Calling a Base Class Method from a Derived Class
    3. 7.3. Overloading Methods of a Base Class
    4. 7.4. Hiding Base Class Methods
    5. 7.5. Implementing Interfaces
    6. 7.6. Understanding Polymorphism
    7. 7.7. Summary
  13. 8. Implementing Object Collaboration
    1. 8.1. Communicating Through Messaging
    2. 8.2. Defining Method Signatures
    3. 8.3. Passing Parameters
    4. 8.4. Understanding Event-Driven Programming
    5. 8.5. Understanding Delegation
    6. 8.6. Implementing Events
    7. 8.7. Responding To Events
    8. 8.8. Windows Control Event Handling
    9. 8.9. Handling Exceptions in the .NET Framework
      1. 8.9.1. Using the Try-Catch Block
      2. 8.9.2. Adding a Finally Block
      3. 8.9.3. Throwing Exceptions
      4. 8.9.4. Nesting Exception Handling
    10. 8.10. Static Properties and Methods
    11. 8.11. Using Asynchronous Messaging
    12. 8.12. Summary
  14. 9. Working with Collections
    1. 9.1. Introducing the .NET Framework Collection Types
    2. 9.2. Working with Arrays and Array Lists
    3. 9.3. Using Generic Collections
    4. 9.4. Programming with Stacks and Queues
    5. 9.5. Summary
  15. 10. Implementing the Data Access Layer
    1. 10.1. Introducing ADO.NET
    2. 10.2. Working with Data Providers
    3. 10.3. Establishing a Connection
    4. 10.4. Executing a Command
    5. 10.5. Using Stored Procedures
    6. 10.6. Using the DataReader Object to Retrieve Data
    7. 10.7. Using the DataAdapter to Retrieve Data
    8. 10.8. Working with DataTables and DataSets
    9. 10.9. Populating a DataTable from a SQL Server Database
    10. 10.10. Populating a DataSet from a SQL Server Database
    11. 10.11. Establishing Relationships between Tables in a DataSet
    12. 10.12. Editing Data in the DataSet
    13. 10.13. Working with the Entity Framework
    14. 10.14. Querying Entities with LINQ to EF
    15. 10.15. Updating Entities with the Entity Framework
    16. 10.16. Summary
  16. 11. Developing Windows Applications
    1. 11.1. Windows Fundamentals
    2. 11.2. Introducing XAML
    3. 11.3. Using Layout Controls
    4. 11.4. Adding Display Controls
    5. 11.5. Using the Visual Studio Designer
    6. 11.6. Handling Control Events
    7. 11.7. Creating and Using Dialog Boxes
    8. 11.8. Presenting a MessageBox to the User
    9. 11.9. Creating a Custom Dialog Box
    10. 11.10. Data Binding in Windows-Based GUIs
    11. 11.11. Binding Controls Using a DataContext
    12. 11.12. Creating and Using Control and Data Templates
    13. 11.13. Summary
  17. 12. Developing Web Applications
    1. 12.1. What Is Silverlight?
    2. 12.2. Creating a Silverlight Application
    3. 12.3. Using Layout Controls
    4. 12.4. Adding Display Controls
    5. 12.5. Handling Control Events
    6. 12.6. Data Binding in Silverlight
    7. 12.7. Validating and Converting Data
    8. 12.8. Summary
  18. 13. Developing and Consuming WCF Services
    1. 13.1. What Are Services?
    2. 13.2. Creating a WCF Web Service
    3. 13.3. Consuming a WCF Web Service
    4. 13.4. Using Data Contracts
    5. 13.5. WCF Data Services
    6. 13.6. Summary
  19. 14. Developing the OSO Application
    1. 14.1. Revisiting Application Design
    2. 14.2. Building the OSO Application's Data Access and Business Logic Layers
    3. 14.3. Creating the OSO Application UI
    4. 14.4. Summary
  20. 15. Wrapping Up
    1. 15.1. Improve Your Object-Oriented Design Skills
    2. 15.2. Investigate the .NET Framework Namespaces
    3. 15.3. Become Familiar with ADO.NET and the Entity Framework
    4. 15.4. Learn More About WPF and Silverlight
    5. 15.5. Move Toward Component-Based Development
    6. 15.6. Find Help
    7. 15.7. Join a User Group
    8. 15.8. Please Provide Feedback
    9. 15.9. Thank You and Good Luck
  21. A. Fundamental Programming Concepts
    1. A.1. Working with Variables and Data Types
    2. A.2. Understanding Elementary Data Types
      1. A.2.1. Integral Data Types
      2. A.2.2. Non-Integral Data Types
      3. A.2.3. Character Data Types
      4. A.2.4. Boolean Data Type
      5. A.2.5. Date Data Type
      6. A.2.6. Object Data Type
      7. A.2.7. Nullable Types
    3. A.3. Introducing Composite Data Types
      1. A.3.1. Structures
      2. A.3.2. Arrays
      3. A.3.3. Classes
    4. A.4. Looking at Literals, Constants, and Enumerations
      1. A.4.1. Literals
      2. A.4.2. Constants
      3. A.4.3. Enumerations
    5. A.5. Exploring Variable Scope
      1. A.5.1. Block-Level Scope
      2. A.5.2. Procedure Scope
      3. A.5.3. Module Scope
    6. A.6. Understanding Data Type Conversion
      1. A.6.1. Implicit Conversion
      2. A.6.2. Explicit Conversion
      3. A.6.3. Widening and Narrowing Conversions
    7. A.7. Working with Operators
      1. A.7.1. Arithmetic Operators
      2. A.7.2. Comparison Operators
      3. A.7.3. Logical Operators
      4. A.7.4. Ternary Operator
    8. A.8. Introducing Decision Structures
      1. A.8.1. If Statements
      2. A.8.2. Switch Statements
    9. A.9. Using Loop Structures
      1. A.9.1. While Statement
      2. A.9.2. Do-While Statement
      3. A.9.3. For Statement
      4. A.9.4. For Each Statement
    10. A.10. Introducing Methods
  22. B. Exception Handling in C#
    1. B.1. Managing Exceptions
    2. B.2. Using the .NET Framework Exception Classes
  23. C. Installing the Required Software
    1. C.1. Installing the Sample Databases
    2. C.2. Verifying the Database Installs

Product information

  • Title: Beginning C# Object-Oriented Programming
  • Author(s):
  • Release date: May 2011
  • Publisher(s): Apress
  • ISBN: 9781430235309