10.6. Summary

In this chapter you learned why constructors exist and why it often makes sense to overload a default constructor. You also learned the details of property methods and how they are part of the user interface for a class. It is the set statement blocks of the property methods that serve as your last line of defense against having a class object put into an undesired state. You should also have a more complete appreciation of how the private access specifier for the class properties helps to safeguard the integrity of the data.

Someone once said, "Practice makes perfect." Well, not really. Perfect practice makes perfect. However, while perfection in writing classes may be your goal, a more reasonable objective right now is to get experience designing and writing classes for objects of your own creation. You are now familiar with the benefits of both UML class and Sideways Refinement design methods. Both are worthwhile tools to hang on your tool belt.

You should spend enough time to answer the exercises at the end of this chapter before moving on to Chapter 11. Having done the exercises, try to think up a few programming problems of your own design. Thinking about programming problems, designing a solution, and then implementing that solution is the only way to learn programming.

Get Beginning C# 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.