Chapter 9

Designing Classes

What you will learn in this chapter:

  • What elements constitute good class design
  • Scope
  • The static storage class
  • Access specifiers
  • Class properties and methods
  • Class components and writing style
  • UML Light
  • General versus helper methods
  • User interfaces

wrox.com code downloads for this chapter

You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118336922 on the Download Code tab. The code in the Chapter09 folder is individually named according to the names throughout the chapter.

Chapter 2 stated that classes are like cookie cutters, and that Visual Studio provides you with a room full of cookie cutters hanging on the wall that you can use. You have used many of those cookie cutters in the sample programs, including labels, textboxes, buttons, listboxes, and listview objects, all of which are extensions of the basic Windows Forms class. Up to this point, you've been writing code that uses those objects in a single class consistently named frmMain. It used this name because all the programs used a single class containing the Main() method that marks the starting point for all C# programs.

Well, it's time to cut the apron strings.

In this chapter, you learn how to make your own cookie cutters to hang on the wall. This chapter concentrates on the design considerations you need to think about to write “good” code for your own classes. A well-designed class becomes another cookie cutter that you can hang on the wall ...

Get Beginning Object-Oriented Programming with C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.