Home Segments Index Top Previous Next

194: Mainline

Smalltalk encourages you to define Smalltalk classes, such as the Vegetable class, that correspond to naturally occurring groups. Once you have defined a class, you can construct any number of instances that belong to that class, each of which corresponds to an individual that belongs to the corresponding group.

When you define the Vegetable class, for example, you indicate that each serving has a protein, carbohydrate, and fat content. Then, you can construct Vegetable instances with particular per-serving protein, carbohydrate, and fat content.

Thus, the employment of classes enables you to create information bundles in your programs, in the form of class instances, that describe naturally occurring individuals. Consequently, classes help you to produce clearer, easier-to-understand programs.