Object-oriented programming helps programmers manage complexity by modeling essential aspects of the real-world problem.
A class defines a new type in your program and is typically used as a representation for a type of thing in the problem domain.
An object is an instance of a class.
State is the current condition of an object.
Many classes define member fields, which are typically private variables visible to every method of the class, but not outside the class.
The behavior of the class is defined with methods, which contain code to perform an action. Methods can manipulate the state of the object and interact with other objects.
The three pillars of object-oriented programming are encapsulation, specialization, and polymorphism.
Encapsulation requires that each class should be discrete and self-contained. Each class should “know” or “do” one discrete thing or set of things.
Specialization is implemented by deriving more specific classes from generalized (base) classes through inheritance.
Polymorphism allows you to treat a collection of objects of types, all derived from a common base, as though each was an instance of that base type.
Analysis is the process of detailing the problem you’re trying to solve.
Design is the planning of the solution to the problem.
This chapter was a bit of a departure from what we’ve been teaching you so far. We got away from the hands-on code to talk in broader terms about object-oriented programming and the theory behind it. That’s an indication of how important these object-oriented concepts are to C#—this is the only time in this book we’ll devote a chapter purely to theory without letting you put your hands on the code. But now that we’ve taken a timeout to teach you the theory, it’s time to get back in the game. Chapter 7 shows you how to create and use classes and objects, and then Chapter 8 goes into more detail about methods.