< Day Day Up > |
Chapter 4. Working with Objects in C#Topics in This Chapter
The purpose of this chapter is to consider what happens to a class when it becomes an object. This metamorphosis raises some interesting questions: What is the best way to create an object? How do you ensure that an object handles errors gracefully? How do you prevent an object from wasting resources (the dreaded memory leak)? What is the best way to work with groups of objects? How do you dispose of an object? Although these questions are unlikely to keep a developer awake at night, their consideration should lead to a keener insight into class design. In an attempt to answer these questions, a variety of topics are presented. These include how to create objects using established design patterns; how to implement the System.Object methods on custom classes; how to implement exception handling; how to persist objects using serialization; and how to use collection classes and interfaces to manage groups of objects. The chapter concludes with a look at how to design an object so that it shuts down properly when subject to .NET Garbage Collection. |
< Day Day Up > |