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:
- In the Business Model layer, click the Classes tab.
- Right-click in the navigator and select New Class.
- Name the class training:
Website
and click Finish. - Click the Overview tab.
- In the Description field, enter
Websites related to entities
. - Set the Caption property to
idsc.training.Website.caption
, and set its en value toWebsite
. - Set the Base Class property to
training:Telcom
. - In the Attributes tab, click the Select button to override the
classCode
attribute. Set the properties for classCode as follows:
Attribute descriptions for WebsiteAttribute Property Value Notes classCode Type string Required true Value "WEBSITE" Include the quotation marks. - 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:
- Navigate to the Persistence Mapping tab for the
training
:Website
class. - Set the Data Source to training:DB.
- Set the Class Code Attribute field to
classCode
. - Set the Primary Table to
Telcom
. - Set the Key Generator to
KeyGenerator.GUIDGen (GUID key generator)
. - Save your changes.
Optionally, update the revision and publish as described in previous lessons.