Lesson 22, “Preventing Bugs,” explains bug proofing techniques that make it easier to detect and
correct bugs. It explains how to use
Assert statements to validate inputs and results so you can
catch bugs quickly rather than letting them remain hidden in the code.
Section IV: Classes
Structures, enumerations, and functions are all programming abstractions that let you think about
pieces of the program at a higher level. When you call the
CalculateInterest function, you don’t
need to know how it works, just that it does.
The ultimate programming abstraction is the class. A class lets you think about data and functions
packaged as a single unit. For example, a
Customer class might include data (name, employee ID,
office number) together with functions (
ScheduleWork, PrintPaycheck).
The lessons in this section deal with classes. They explain how to create and use classes and how to
use more advanced class features such as generics and operator overloading.
Lesson 23, “Defining Classes,” explains how to define classes. It explains the three fundamental
characteristics of object-oriented classes (inheritance, encapsulation, and polymorphism) and how
classes provide them. It explains how to build simple properties and methods.
Lesson 24, “Initializing Objects,” explains constructors, destructors, and initializers, and shows
how to use them to make creating objects easier.
Lesson 25, “Fine-Tuning Classes,” explains how you can overload and override class methods. These
techniques let you make classes more flexible and easier to use.
Lesson 26, “Overloading Operators,” explains operator overloading. This technique lets you define
the behavior of operators such as +, *, and % for objects other than numbers.
Lesson 27, “Using Interfaces,” explains what a class interface is and how to build one. Just as a
program’s user interface defines the features that a user sees, a class interface defines the features
that a class must have to implement the interface.
Lesson 28, “Making Generic Classes,” explains how to build new generic classes. Whereas Lesson 16
shows how to use generic collection classes such as
Hashtable to work with different kinds of data,
this lesson explains how you can build your own generic classes and methods.
Section V: System Interactions
Earlier lessons explain how to let a program interact with the user. The lessons in this section
explain methods a program can use to interact with the operating system and other programs.
Lesson 29, “Reading and Writing Files,” explains how a program can read and write files. It
explains how to use streams to manipulate the text in a file all at once or in pieces, for example,
one line at a time.
Lesson 30, “Using File System Classes,” explains ways in which a program can use classes to find,
examine, and manipulate directories and files. It describes file handling classes such as
DriveInfo,
DirectoryInfo, Directory, and FileInfo.
596906flast.indd 32 4/7/10 12:31:17 PM