- 24 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Superclasses and Subclasses
- Updated on 24 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Overview
Superclasses are components of data inheritance where certain properties, attributes, or characteristics of an entity are inherited or passed down from a parent object to its child objects or entities. Superclasses function as the highest tier of classification within a structure. They encapsulate shared attributes common to all descendant elements in the child classes. This setting is available in Flow Structures, Defined Data Structures, and Entities. Superclasses, often referred to as parent classes, pass down their properties and characteristics to their subclasses.
Use Cases
Example Use Case | Description |
---|---|
Investment Products | Financial institutions often offer a range of investment products like stocks, bonds, and mutual funds. Using inheritance, create a superclass that captures shared attributes like market value and risk level, with subclasses specifying details unique to each investment type. |
Payment Processing | Payment processing systems can benefit from inheritance to handle different payment methods. A superclass might contain general payment information, while subclasses represent specific payment types like credit cards, electronic funds transfers, or cryptocurrencies. |
Medical Conditions | In healthcare systems, you can model medical conditions with a superclass, including common attributes like a diagnosis date and treatment plan. Subclasses could represent specific conditions such as diabetes, hypertension, or allergies, each with its unique treatment protocols. |
Patient Records | In a healthcare database, patient records can be structured using inheritance. A superclass might include general patient information, while subclasses capture details related to specific patient types, such as inpatient, outpatient, or pediatric records. |
Create a Superclass
- In a Designer Project, click CREATE DATATYPES/INTEGRATIONS and click Defined Data Structure.
- In the Structure Type Name field, enter "Payment". This will be the superclass.
- Under Name, enter the following data members: Payment ID, Payment Amount, Payment Date, Payment Method, Payment Status. Click SAVE.
Create a Subclass
- In the same Designer Project, click CREATE DATATYPES/INTEGRATIONS and select Defined Data Structure.
- Enter a Payment Method like "CreditCardPayment" or "ElectronicFundsTransfer" in the Structure Type Name field.
- Under the ADVANCED category, enter the superclass type namespace in the Super Class field.The Superclass input utilizes both the Type Name Space and the Structure Type namespace of the superclass to determine which class to inherit traits from. The input is case sensitive and is formatted as the Type Name Space, a period, and then the Structure Type Name.
- Define data fields under Name and configure the Type for each. Click SAVE to create the subclass.
CreditCardPayment | ElectronicFundsTransfer |
---|---|
CardholderName | Bank Name |
Card Number | Account Holder |
Expiry Date | Account Number |
CVV | Routing Number |
Billing Address | Transaction Reference |
Expected Result
In a Flow, set up two types of data structures: "CreditCardPayment" and "Payment." These structures are used as inputs on a Create Data step. Select Build Data as the mapping type for both inputs to see the data fields within each structure. Notice that the CreditCardPayment structure has successfully inherited the data fields from the Payment structure.