Show TOC

 Creating and Defining MethodsLocate this document in the navigation structure

Methods describe how an object behaves. You implement them using functions defined within classes. Functions are operations that change the attributes of a class or interface. There are instance and static methods. Instance methods refer to a certain class instance, whereas static methods are common to all the class instances. Static methods can only address static attributes.

There are also special methods like constructors and class constructors. You do not need to create these classes explicitly if you do not plan to implement them.

Prerequisites

The class or interface to which you want to apply the method already exists.

Note

It is useful if you have already created the attributes of the class, since you can branch directly from a method definition in the Class Builder to its implementation.

Procedure
  1. Open the class you want to edit.
  2. Choose the Methods tab page.
  3. To create a method, make the following entries:
    Option Description

    Method

    Name of the method

    Level

    Specifies the method as an instance method or a static method

    Visibility

    Define the visibility of methods for the user of the class. Public assigns the method to the public area of the class and the method can be called by every user of the class. If you make the method protected, it is visible to and can be used by the class itself and any of its subclasses. If the method is private, it is only visible in and available to the class itself. Private methods do not form part of the external point of contact between the class and its users. If a method is assigned to the package section, it is visible only in the package of the class and can be called only from another object of this package.

    Method Type

    The method type specifies whether the method is a normal method, an event handler, a constructor, a destructor, or the GET method or SET method of a virtual attribute.

    Description

    Short description of the method.

  4. Save your entries.
Result

You have created methods for an object type. They are included in the definition part of the class or interface, that is, generated into the corresponding class pool or interface pool. Before you can implement the methods, you must create your parameters and exceptions.

See also:

Creating Parameters and Exceptions

Implementing Methods

Creating Event Handler Methods