Skip to main content
Skip table of contents

Revisiting class inheritance

In this lesson you review how to create a derived class. This is in preparation for the next module. By completing this module, you will:

  • Gain additional practice in creating a subclass.
  • Prepare your model for the exercises in the upcoming lesson.

Create a Website class

To prepare for the next module, you need to create a new subclass of training:Telcom called training:Website. training:Website should extend training:Telcom, and customize the classCode attribute with a value of "WEBSITE". However, it won't have any new attributes, as the already-inherited address attribute can store the URL information and the name attribute can store the name of the website.

Try creating this class now, making use of the Class Table persistence pattern, as applicable. When you are finished, update the model diagram. It should resemble the following:

Check what you have done

Use the following steps to check what you have created or to walk you through the creation of the training:Website class.

Create the Website class

To create the Website class:

  1. In the Business Model layer, click the Classes tab.
  2. Right-click in the navigator and select New Class.
  3. Name the class training:Website and click Finish.
  4. Click the Overview tab.
  5. In the Description field, enter Websites related to entities.
  6. Set the Caption property to idsc.training.Website.caption, and set its en value to Website.
  7. Set the Base Class property to training:Telcom.
  8. In the Attributes tab, click the Select button
    to override the classCode attribute.
  9. Set the properties for classCode as follows:

    Attribute descriptions for Website

    AttributePropertyValueNotes
    classCodeTypestring
    Requiredtrue
    Value"WEBSITE"Include the quotation marks.
  10. Save your changes.

Define persistence mapping

Even though the classCode attribute was customized for this class, no new attributes were defined, so no changes need to be made to the Persistence layer of the model. All that needs to be done is to set some of the properties for the class' persistence mapping.

To define persistence mapping:

  1. Navigate to the Persistence Mapping tab for the training:Website class.
  2. Set the Data Source to training:DB.
  3. Set the Class Code Attribute field to classCode.
  4. Set the Primary Table to Telcom.
  5. Set the Key Generator to KeyGenerator.GUIDGen (GUID key generator).
  6. Save your changes.

Optionally, update the revision and publish as described in previous lessons. 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.