space
Previous Page | Next Page

Moving Legacy Classes to the SAS Component Object Model

Creating New Components from Legacy Classes

You can use legacy classes (that is, classes that were created with Version 6 of SAS/AF software) to create new components. If you first conduct a thorough analysis of the class that you want to enhance, the design process is straightforward.

To analyze the legacy class:

  1. Review the list of instance variables that the legacy class uses to determine which instance variables you want to surface as attributes. You should also consider the scope of the attributes; set the scope to PROTECTED or PRIVATE for those instance variables that you turn into attributes and that you do not want other classes to be able to access.

  2. For each instance variable that you want to convert to an attribute, determine

    • a more descriptive name. For example, use description instead of desc.

    • a list of valid values for the new attribute, including its initial value.

    • whether the attribute requires a more complex dialog box for selecting valid values and how that dialog box might work. For example, users could select values for a color attribute from a Colors dialog box.

    • whether any existing legacy methods that the class provides are used in SCL programs to retrieve (get) or set the value of the instance variable.

      Note:   For Version 6 of SAS/AF software, it was recommended that developers supply methods for changing object behavior through instance variables instead of setting the value of the instance variable directly. Attributes now provide better ways of manipulating objects without using methods directly.  [cautionend]

To design and implement the new component:

  1. In the SAS Explorer, right-click on the legacy class that you want to use to create a new class and then select Copy.

  2. In the SAS Explorer, open the catalog in which you want to create your new class, then right-click your mouse and select Paste.

    Note:   You can also convert a legacy class by first using the CREATESCL SCL function, adding the appropriate property information in the CLASS/ENDCLASS definition, and then saving the SCL entry as a class. See the CREATESCL function and the CLASS statement in SAS Component Language: Reference for details.  [cautionend]

  3. Select the copied class, then select Open from the pop-up menu.

  4. In the Class Editor, modify properties (such as attributes, methods, events, or event handlers) as needed.

    Instance variables appear as attributes in the Class Editor. Most of your conversion work may involve setting attribute metadata in the Class Editor.

  5. Select View [arrow] Class Settings to set build-time options for the class. You can

    • select Use Properties window to indicate that you want to use the Properties window to set properties for instances of the class on a frame.

    • select the Use Custom Attributes Window to indicate that you want to continue to use a custom attributes window for setting attribute values. You can include the name of the FRAME entry that contains the custom attributes window.

    Click OK to return to the Class Editor.
  6. Select Attributes from the Properties view. Change the value of the objectNameUsage attribute from value to ID.

    Note:   In Version 6, the name of the object represented the value of the object. Currently, the name of the object is used to represent the object identifier. Setting the objectNameUsage attribute to ID enables you to use the object name as an ID in SCL programs that use dot notation.  [cautionend]

  7. Select File [arrow] Close to close the Class Editor and save your changes.

space
Previous Page | Next Page | Top of Page