Partager via


Considerations for Creating Classes

There are many different contexts for creating and using classes and subclasses. However, using strategic planning, you can determine more effectively which classes you need to design and the type of functionality to include in those classes. When creating classes, remember the following considerations.

  • Be selective when creating classes.

    Though you can create a class for every control and form you might want to use, this strategy might not be the most effective way to design your application. The result might be that you have many classes that perform the same task but need to be maintained separately.

  • Create and use control classes for encapsulating generic functionality.

    You can provide generic functionality in your application creating control classes. For example, you can create command buttons that users click to move record pointers in tables, close forms, or open a Help file and save them as classes so you can add the controls to forms.

    You can expose properties and methods on a class so that the user can integrate them into the particular data environment of a form or form set.

  • Determine the functionality you want to include for classes at the class level, subclass level, and object level in advance.

    When you create subclasses and objects from the classes you create, you can include additional properties, methods, and events in those subclasses, and by extension, objects created from those classes. You can also choose to override default property values as well as method and event code as specified by the original class.

  • Provide a consistent look and feel for your application.

    You can create form, form set, and control classes with a distinctive appearance so that all the components of your application have the same look. For example, you can add graphics and specific color patterns to a form class and use that class as a template for all forms you create. You can create a text box class with a distinctive appearance, such as a shadowed effect, and use this class throughout your application any time you want to add a text box.

See Also

Tasks

How to: Create Classes and Subclasses

Concepts

Classes in Visual FoxPro

Working with Classes in Visual FoxPro