General Rules and Purpose of Subclassing

From MorphOS Library

Revision as of 10:02, 30 December 2010 by Krashan (talk | contribs) (Started.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Grzegorz Kraszewski


Introduction

Subclassing is one of essential object oriented programming techniques. In MUI subclassing is used for the following purposes:

  • Implementing program functionality as a set of methods. The Application class is usually used for this purpose.
  • Customizing classes by writing methods intentionally left unimplemented (or having some default implementations) in standard MUI classes. The most common example is the List class, but also Numeric one and others.
  • Writing custom drawn gadgets or areas. The Area class is subclassed in this case.

Regardless of the reason of subclassing, it is always done in the same way. A programmer must write new or overridden methods, create a dispatcher function, define an instance data structure (empty one in some cases), then create the class.