Guide to C# and Object Orientation / Edition 1

Guide to C# and Object Orientation / Edition 1

by John Hunt
     
 

This book shows readers how to get the most out of C# using Object Orientation. The author takes a hands-on approach to learning C# and object orientation, using lots of worked examples. The text provides an ideal base from which to start programming. After introducing the C# language and object orientation, John Hunt goes on to explain: how to construct a user

See more details below

Overview

This book shows readers how to get the most out of C# using Object Orientation. The author takes a hands-on approach to learning C# and object orientation, using lots of worked examples. The text provides an ideal base from which to start programming. After introducing the C# language and object orientation, John Hunt goes on to explain: how to construct a user interface for a simple editor; how to obtain information on files and directories and how objects can be stored and restored using serialization...

-Presents C# and object-orientation as a coherent whole, using one to strengthen the presentation of the other -Includes lots of complete and worked examples to clarify readers'understanding -The source code for the examples is available at: http://www.guide-to-csharp.net -Hunt is a successful Springer author, and this book is written in the same style as his Java for Practitioners

Product Details

ISBN-13:
9781852335816
Publisher:
Springer London
Publication date:
10/03/2002
Edition description:
2002
Pages:
476
Product dimensions:
1.13(w) x 10.00(h) x 7.00(d)

Meet the Author

Table of Contents

1 Introduction to Object Orientation.- 1 Introduction to Object Orientation.- 1.1 Introduction.- 1.2 Programming Paradigms.- 1.3 Revolution Versus Evolution.- 1.4 Why Learn a New Programming Paradigm?.- 1.4.1 Software Industry Blues.- 1.4.2 The Advantages Claimed for Object Orientation.- 1.4.3 What Are the Problems and Pitfalls of Object Orientation?.- 1.5 Fundamentals of Object Orientation.- 1.6 The Basic Principles of Object Orientation.- 1.7 Encapsulation.- 1.8 Inheritance.- 1.9 Abstraction.- 1.10 Polymorphism.- 1.10.1 Overloading Operators.- 1.10.2 Overriding Operators.- 1.11 Summary.- 1.12 Further Reading.- 2 Elements of Object Orientation.- 2.1 Introduction.- 2.2 Terminology.- 2.3 Types of Hierarchy.- 2.4 The Move to Object Technology.- 2.5 Summary.- 2.6 Exercises.- 2.7 Further Reading.- 2 Introduction to the C# Language.- 3 Why Object Orientation?.- 3.1 Introduction.- 3.2 The Procedural Approach.- 3.2.1 A Naked Data Structure.- 3.2.2 Procedures for the Data Structure.- 3.2.3 Packages.- 3.3 Does Object Orientation Do Better?.- 3.3.1 Packages Versus Classes.- 3.3.2 Inheritance.- 3.4 Summary.- 4 Constructing an Object-Oriented System.- 4.1 Introduction.- 4.2 The Application: Windscreen Wipe Simulation.- 4.3 Where Do We Start?.- 4.4 Identifying the Objects.- 4.5 Identifying the Services or Methods.- 4.6 Refining the Objects.- 4.7 Bringing it all Together.- 4.8 Where is the Structure?.- 4.9 Summary.- 4.10 Exercises.- 4.11 Further Reading.- 5 An Introduction to C#.- 5.1 Introduction.- 5.2 Background.- 5.3 What Is C#?.- 5.4 Objects in C#.- 5.5 Commercial Versions of C#.- 5.6 The C# Environment.- 5.7 Comparing C# to Java and C++.- 5.8 C# Keywords.- 5.9 Where to Get More Information.- 6 A Little C#.- 6.1 Introduction.- 6.2 Setting Up the Development Environment.- 6.3 Compiling and Executing C#.- 6.4 Summary.- 7 C# Classes.- 7.1 Introduction.- 7.2 The Basics of the Language.- 7.2.1 Some Terminology.- 7.2.2 The Message-Passing Mechanism.- 7.2.3 The Statement Terminator.- 7.3 Classes.- 7.3.1 Class Definitions.- 7.3.2 Classes and Messages.- 7.3.3 Instances and Instance Variables.- 7.3.4 Classes and Inheritance.- 7.3.5 Instance Creation.- 7.3.6 Constructors.- 7.3.7 Static Constructors Blocks.- 7.3.8 Finalize Methods.- 7.3.9 Supplied Classes.- 7.4 Method Definitions.- 7.4.1 The Comments Section.- 7.4.2 The Local Variables Section.- 7.4.3 The Statements Section.- 7.4.4 The Return Operator.- 7.4.5 An Example Method.- 7.4.6 Static Fields and Methods.- 7.4.7 Constants.- 7.4.8 Read-Only Fields.- 7.4.9 Properties and Indexers.- 8 Structs and Enumerations.- 8.1 Introduction.- 8.2 Structs in C#.- 8.3 Initialization of Structs.- 8.4 Structs and Constructors.- 8.5 Immutable Structs.- 8.6 Enumerations.- 8.7 Enumeration Foundations.- 8.8 Initialization of Enumeration Values.- 8.9 Zero and Enumerations.- 8.10 Bit Flag Enumerations.- 8.11 System Support for Enumerations.- 9 Interfaces.- 9.1 Introduction.- 9.2 Interface Definitions.- 9.3 Interfaces Versus Abstract Classes.- 9.4 Implementing an Interface.- 9.5 Using Interfaces.- 9.6 Multiple Inheritance and Interfaces.- 9.7 Implementing Interfaces and Extending a Superclass.- 9.8 Method Hiding.- 9.9 Interfaces and Structs.- 10 C# Constructs.- 10.1 Introduction.- 10.2 Data Types.- 10.3 Numbers and Numeric Operators.- 10.3.1 Numeric Values.- 10.3.2 Built-In Arithmetic Operators.- 10.3.3 User-Defined Operators.- 10.3.4 Type Operators.- 10.4 Assignments.- 10.5 Compound Assignment.- 10.6 Variables.- 10.6.1 Temporary Variables.- 10.6.2 The this Pseudo-Variable.- 10.6.3 Variable Scope.- 10.6.4 Special Values - true, fal se and null.- 10.7 Messages and Message Selectors.- 10.7.1 Invoking Methods.- 10.7.2 Precedence.- 10.8 Checked and Unchecked Expressions.- 10.9 Summary.- 11 Characters and Strings.- 11.1 Introduction.- 11.2 Characters.- 11.3 Strings.- 11.4 Converting Objects to Strings.- 11.5 Strings and Stri ngBui l der.- 11.6 Regular Expressions.- 11.7 String Formatting.- 11.8 String Encoding.- 12 An Example C# Class.- 12.1 Introduction.- 12.2 Defining a Class.- 12.2.1 Creating the Class.- 12.3 Defining a Constructors and Methods.- 12.3.1 The Main Method.- 12.3.2 The Constructor.- 12.3.3 The Properties.- 12.3.4 The Birthday Method.- 12.4 Creating an Instance.- 3 C# and Object Orientation.- 13 Classes, Inheritance and Abstraction.- 13.1 Introduction.- 13.2 Classes Revisited.- 13.2.1 What Are Classes For?.- 13.2.2 Class-Side Methods.- 13.2.3 A Class or an Instance.- 13.3 Inheritance in Classes.- 13.3.1 The Role of a Subclass.- 13.3.2 Capabilities of Classes.- 13.3.3 Overriding Methods.- 13.3.4 Restricting a Subclass (Sealed Classes).- 13.4 Abstract Classes.- 13.5 Constructors and Their Use.- 13.6 Calling Superclass Constructors.- 13.7 The Mai n Method.- 14 Encapsulation and Polymorphism.- 14.1 Introduction.- 14.2 Encapsulation.- 14.2.1 Class Modifiers.- 14.2.2 Variable Modifiers.- 14.2.3 Method Modifiers.- 14.3 Namespaces.- 14.3.1 Declaring a Namespace.- 14.3.2 Assemblies.- 14.3.3 Using Namespaces.- 14.3.4 Compiling Using Assemblies.- 14.4 Polymorphism.- 14.4.1 Dynamic or Late Binding.- 14.4.2 Method Selection/Overloading.- 14.4.3 Method Hiding.- 14.4.4 Variable-Length Parameter Lists.- 15 Nested Classes.- 15.1 Introduction.- 15.2 What Are Nested Classes?.- 15.3 How and When Should I Use Nested Classes?.- 15.3.1 As Helper Classes.- 15.3.2 As Event Handlers.- 15.3.3 As a Way of Overcoming Single Inheritance.- 15.3.4 Laying Out a C# Class With Nested Classes.- 15.3.5 Nested Class Guidelines.- 16 Arrays in C#.- 16.1 Introduction.- 16.2 Arrays.- 16.2.1 Arrays of Objects.- 16.2.2 Basic Type Arrays.- 16.2.3 Multi-Dimensional Arrays.- 16.2.4 Jagged/Ragged Arrays.- 16.2.5 Array Conversions.- 16.2.6 System. Array.- 16.2.7 The Mai n Method.- 16.2.8 Arrays and Methods.- 17 The Collections API.- 17.1 Introduction.- 17.2 Data Structure Classes.- 17.3 What Is in the Collections API?.- 17.4 Collection Interfaces.- 17.5 The core interfaces.- 17.5.1 ICol l ecti on.- 17.5.2 I Li st.- 17.5.3 The IDi cti onary interface.- 17.6 Comparisons.- 17.7 Abstract Implementations.- 17.7.1 Col l ecti onBase.- 17.7.2 ReadOnlyCol 1 ectionBase.- 17.7.3 Di cti onaryBase.- 17.8 Concrete Implementations.- 17.8.1 ArrayLi st.- 17.8.2 Bi tArray.- 17.8.3 The Hashtabl e class.- 17.8.4 Sorted Li st Collection Class.- 17.8.5 The Queue Class.- 17.8.6 The Stack Class.- 17.9 The System. Col l ecti ons. Speci al i zed namespace.- 17.10 Enumeration.- 17.11 Iteration over Dictionaries.- 17.12 Summary.- 18 An Object-Oriented Organizer.- 18.1 Introduction.- 18.2 The 0rgani zer Class.- 18.3 The Class Definition.- 18.4 The Updating Prool.- 18.5 The Accessing Prool.- 18.6 The Mai n Method.- 18.7 The Full Listing.- 18.8 Exercise - the Financial Manager Project.- 4 Further C#.- 19 Control and Iteration.- 19.1 Introduction.- 19.2 Control Structures.- 19.2.1 The I f Statement.- 19.2.2 The Conditional Operator.- 19.2.3 The switch Statement.- 19.3 Iteration.- 19.3.1 for Loops.- 19.3.2 while Loops.- 19.3.3 do Loops.- 19.3.4 foreach.- 19.3.5 break and continue.- 19.3.6 The goto Statement.- 19.3.7 An Example of Loops.- 19.4 Recursion.- 19.5 Summary.- 20 Attributes and Versioning.- 20.1 Introduction.- 20.2 Attributes.- 20.2.1 What Are Attributes?.- 20.2.2 Using Attributes.- 20.2.3 Conditional Attributes.- 20.2.4 User-Defined Attributes.- 20.2.5 Attribute Parameters.- 20.3 Versioning.- 21 Delegates.- 21.1 Introduction.- 21.2 Delegates.- 21.3 Delegates in C#.- 21.4 Defining a Delegate.- 21.5 Static and Instance Methods.- 21.6 Multicasting.- 21.7 Delegates as Static Properties.- 21.8 Usage.- 21.9 Summary.- 22 Exception Handling.- 22.1 Introduction.- 22.2 What Is an Exception?.- 22.3 What Is Exception Handling?.- 22.4 Throwing an Exception.- 22.5 Catching an Exception.- 22.6 Defining an Exception.- 22.6.1 Nesting Exceptions.- 5 Graphical User Interfaces.- 23 Graphical User Interfaces.- 23.1 Introduction.- 23.2 Windows Forms Overview.- 23.3 The Control Class.- 23.4 The Form Class.- 23.5 Building Up a GUI.- 23.6 Using Panels Within Forms.- 23.7 Docking.- 23.8 Anchoring.- 24 Event Handling.- 24.1 Introduction.- 24.2 Event Handling in General.- 24.3 Event Handling in C#.- 24.4 The Inner Workings.- 24.5 An Example.- 25 The JDEdit Application.- 25.1 Introduction.- 25.2 JDEdit.- 25.3 The Structure of JDEdit.- 25.4 The Menu Bar and Menus.- 25.5 The RichTextBox Setup.- 25.6 Monitoring the Application Closure.- 25.7 The Full Listing.- 6 C# Development.- 26 Streams and Files.- 26.1 Introduction.- 26.2 Files.- 26.3 Filelnfo.- 26.4 Directory and Directorylnfo.- 26.5 Streams.- 26.5.1 What Is a Stream?.- 26.5.2 Using the IO Classes.- 26.6 Summary.- 27 Serialization.- 27.1 Introduction.- 27.2 Binary Serialization.- 27.2.1 Saving Objects.- 27.2.2 Reading Objects.- 27.3 XML Serialization.- 27.3.1 Saving Objects.- 27.3.2 Reading Objects.- 27.4 Controlling Serialization.- 27.5 Custom Serialization.- 27.6 Summary.- 28 Sockets in C#.- 28.1 Introduction.- 28.2 Socket to Socket Communication.- 28.3 Setting up a Connection.- 28.4 An Example Client-Server Application.- 28.4.1 The System Structure.- 28.4.2 Implementing the Server Application.- 28.4.3 Implementing the Client Application.- 29 Data Access.- 29.1 Introduction.- 29.2 OLE DB.- 29.3 Registering a Provider.- 29.4 Opening a Connection.- 29.5 Creating a Table.- 29.6 Obtaining Data From a Database.- 29.6.1 Full Listing.- 29.7 Accessing SQL Server.- 29.8 ODBC.- 29.8.1 What Is ODBC?.- 29.8.2 Using ODBC.- 29.9 Exploiting ADO.NET.- 29.10 Further Reading.- 30 Remoting in.NET.- 30.1 Introduction.- 30.2 Remoting.- 30.2.1 Selecting the Type of Channel.- 30.2.2 Subclassing a Server Class.- 30.2.3 The Hel 1 oCl i ent.- 30.2.4 Running the Application.- 30.2.5 What Is Happening?.- 30.3 Remoting Details.- 30.3.1 Remote Objects and Channels.- 30.3.2 Server-Side Registration.- 30.3.3 Default Lifetime.- 30.3.4 Well-Known Objects.- 30.3.5 Client-Activated Objects.- 30.3.6 Programmatic Configuration.- 31 Concurrency.- 31.1 Introduction.- 31.2 Concurrent Processes.- 31.3 Threads.- 31.3.1 Thread States.- 31.3.2 Creating a Thread.- 31.4 The Thread Class.- 31.4.1 Implementing a Thread.- 31.4.2 Asynchronous Method Calls.- 31.4.3 Joining Threads.- 31.4.4 Synchronization.- 31.5 A Producer/Consumer Example.- 32 Using C# in ASP.NET.- 32.1 Introduction.- 32.2 What Is an ASP?.- 32.3 A Very Simple JSP.- 32.4 ASP.NET Tags.- 32.4.1 ASP Directives.- 32.4.2 Code Declaration Blocks.- 32.4.3 Server-Side Object Tag Syntax.- 33 Web-Based User Interfaces.- 33.1 Introduction.- 33.2 Web Forms Overview.- 33.3 The Control Class.- 33.4 The Page Class.- 33.4.1 The System. Web.UI.WebControls Namespace.- 33.4.2 The System. Web.UI.Html Control s Namespace.- 33.5 Building up a Web Page.- 33.5.1 Basic ASP.- 33.5.2 Using a Page class.- 34 XML and C#.- 34.1 Introduction.- 34.2 XML Introduced.- 34.2.1 What is XML?.- 34.2.2 What Do XML Documents Look Like?.- 34.2.3 XML Vocabularies.- 34.2.4 Working With DTD.- 34.3 The DOM API.- 34.4 The DOM in C#.- 34.5 Creating an XML Document in C#.- 34.6 Loading an XML Document in C#.- 35 C# Style.- 35.1 Introduction.- 35.2 Code Layout.- 35.3 Variables.- 35.3.1 Naming Variables.- 35.3.2 Using Variables.- 35.4 Classes.- 35.4.1 Naming Classes.- 35.4.2 The Role of a Class.- 35.4.3 Creating New Data Structure Classes.- 35.4.4 Class Comments.- 35.4.5 Using a Class or an Instance.- 35.5 Interfaces.- 35.6 Methods.- 35.6.1 Naming Methods.- 35.6.2 Using Methods.- 35.6.3 Class Methods and Instance Methods.- 35.6.4 Constructors.- 35.6.5 Static Constructors.- 35.6.6 The Destructor Method.- 35.6.7 Programming in Terms of Objects.- 35.6.8 Positioning of Methods.- 35.7 Scoping.- 36 C# Roundup.- 36.1 Introduction.- 36.2 Memory Management.- 36.2.1 Why Have Automatic Memory Management?.- 36.2.2 Memory Management in C#.- 36.2.3 When Is Garbage Collection Performed?.- 36.3 Conversion of Classes.- 36.4 The Mai n Method.- 36.5 Compiler Directives.- 36.6 Assertions, Debugging and Tracing.- 36.6.1 Debugging and Tracing.- 36.6.2 Assertions.- 36.7 Using Pointers in C#.- 37 The.NET Environment.- 37.1 Introduction.- 37.2.NET Overview.- 37.3 The.NET Framework.- 37.3.1 Common Language Runtime.- 37.3.2 Framework Class Library.- 37.4.NET My Services.- 37.5 Language Interoperability.- 7 Object-Oriented Design.- 38 Object-Oriented Analysis and Design.- 38.1 Introduction.- 38.2 Object-Oriented Design Methods.- 38.3 Object-Oriented Analysis.- 38.4 The Booch Method.- 38.4.1 The Steps in the Booch Method.- 38.4.2 Strengths and Weaknesses.- 38.5 The Object Modeling Technique.- 38.5.1 The Analysis Phase.- 38.5.2 The Design Phase.- 38.5.3 The Implementation Phase.- 38.5.4 Strengths and Weaknesses.- 38.6 The Objectory Method.- 38.6.1 The Requirements Phase.- 38.6.2 The Analysis Phase.- 38.6.3 The Construction Phase.- 38.6.4 Strengths and Weaknesses.- 38.7 The Fusion Method.- 38.8 The Unified Modeling Language.- 38.9 Summary.- 39 The Unified Modeling Language.- 39.1 Introduction.- 39.2 The Meta-Model.- 39.3 The Models.- 39.4 Use Case Diagrams.- 39.5 The Object Model.- 39.5.1 Representing Classes.- 39.5.2 Representing Objects.- 39.5.3 Representing Relationships.- 39.6 Packages.- 39.7 Sequence Diagrams.- 39.8 Collaboration Diagrams.- 39.9 State Machine Diagrams.- 39.9.1 Start Points.- 39.9.2 Events.- 39.9.3 A Set of Transitions.- 39.9.4 A Set of State Variables.- 39.9.5 A Set of States.- 39.9.6 A Set of Exit Points.- 39.10 Deployment Diagrams.- 39.11 Summary.- 40 The Unified Process.- 40.1 Introduction.- 40.2 The Unified Process.- 40.2.1 Overview of the Unified Process.- 40.2.2 Life Cycle Phases.- 40.2.3 Phases, Iterations and Workflows.- 40.2.4 Workflows and Activities.- 40.3 Requirements Workflow.- 40.3.1 Interface Descriptions.- 40.4 Analysis Workflow.- 40.4.1 Analysis Model Classes.- 40.4.2 Constructing the Analysis Model.- 40.5 Design Workflow.- 40.5.1 Identifying Classes.- 40.5.2 Refining the Set of Classes.- 40.5.3 Identifying and Refining Attributes.- 40.5.4 Identifying and Refining Operations.- 40.5.5 Design Use Case Realizations.- 40.5.6 Generating a Sequence Diagram.- 40.5.7 Building a Statechart Diagram.- 40.5.8 Identifying and Refining Associations.- 40.5.9 Identifying Interfaces and Inheritance.- 40.5.10 Remaining Steps.- 40.6 Implementation Workflow.- 40.7 Testing Workflow.- 40.8 Summary.- References.

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >