Show in Frame No Frame
Up Previous Next Title Page Contents Search

5.1 Person as Male and Female

In our Family Tree language, we now have one concept of Person with properties of First name and Family name. We know, however, that in most cases we probably would like to store more information than that about each Person. For most applications it would be desirable to know dates for a Person’s birth and death. Furthermore, as a female Person may change her family name when she gets married, storing the maiden name separately for a female Person would be a useful feature. In diagrams, we could also want to have a different symbol for male and female persons.

Now all of this obviously calls for a specialization of the concept of Person into concepts of Male and Female. However, as these two new concepts are straight subtypes of Person, we want to present this semantic fact in our metamodel also. Thus we assign all common properties to the concept of Person, define Male and Female as its subtypes, and add additional properties to Male and Female where needed. Figure 5-1 presents a new version of the Family Tree modeling language metamodel with these changes.

Family Tree advanced metamodel

Figure 5-1. Family Tree metamodel with specialized Male and Female objects.

Now we are going to make the same changes to our metamodel in MetaEdit+. Start the Object Tool by pressing Object Tool toolbar button or selecting Metamodel | Object Tool in MetaEdit+ launcher. In the Object Tool press the Open button on the toolbar or select Object | Open.... If ‘Person’ is the only object type currently defined, it will be opened immediately – otherwise select it from the list dialog. You now have the definition for Person in your Object Tool. Go to the Properties list and add a property, choosing to create a new property type. In the Property tool, enter ‘Date’ as the name. As the default data type (String) and widget (Input Field) are correct, press Save and Close (accept the addition of the property if asked) and go back to the Object Tool. Select the newly created ‘Date’ property from the property list and open its pop-up menu by pressing the right mouse button. Select Local name..., enter ‘Date of birth’ into the dialog that opens and press OK.

The local name was used here as a mechanism for reuse: the same property may have several local names to make it more suitable for various purposes. This will be further demonstrated as we create the ‘Date of death’ property. As we have already defined a property of Date, we do not now need to create a completely new property type, but we can reuse the existing one. First, Ctrl+click the ‘Date of birth’ property slot to no property is selected in the Property list (so the new property will be added at the end), and choose Add Property... from the Property list pop-up menu. This time choose property type ‘Date’ from the list instead of ‘New Property Type’, and change its local name to ‘Date of death’ the same way you did with ‘Date of birth’. Now you have reused one property type, ‘Date’, as both the date of birth and the date of death. Your Object Tool should now look similar to the one in Figure 5-2.

Object Tool with more properties

Figure 5-2. Object Tool with more properties.

Press the Save button to accept the modifications. What we want to do next is to create new types Male and Female as subtypes of Person. In the Object Tool, select Object | New Subtype... from the menu, select ‘Person’ from the list of possible ancestor types, and press OK. You are now creating a new Object type with properties inherited (and thus shown red) from the Person object. As the concept of Male actually adds nothing to the concept of Person, we can now create the Male object by entering ‘Male’ as the name in this new Object Tool. Then press Save.

As Male is a concept which we are going to use in our diagrams, we need to define a graphical symbol for it. Start the Symbol Editor, import the symbol called ‘Male’ from the symbol library and modify it to use true properties instead of fixed text for the four text fields named after properties (leave ‘Birth’ and ‘Death’ as fixed text), as you did with the original ‘Person’ symbol. To make a connectable that more accurately traces the rounded outline of the symbol, select the outer rounded rectangle and from its pop-up menu choose Duplicate As | Connectable (Figure 5-3). Save the symbol and close the Symbol Editor.

Symbol Editor with Male symbol

Figure 5-3. Symbol Editor with the completed symbol for Male.

Creating the Female object requires a little more work. Start again by creating a new type as a descendant of Person (i.e. select Object | New Subtype... and select ‘Person’ – not ‘Male’! – as the ancestor). Enter ‘Female’ as the name for this new descendant, and add an extra property (reuse the ‘Family name’ property type), then give it a local name of ‘Maiden name’. At the end, the Object Tool for the Female object should look like Figure 5-4.

Object Tool for Female

Figure 5-4. Object Tool for Female object

Press Save, (allow the default dialog to be created if asked), and create the symbol for the Female object in the same way you did for Male: load the ‘Female’ symbol from the symbol library, assign real properties for the five appropriate text fields, duplicate the outermost rectangle as a connectable and save the symbol. You can now close the Symbol Editor and the Object Tool.

Symbol Editor with Female symbol

Figure 5-5. The Symbol Editor with symbol for Female

Commit your work and start the Graph Tool by clicking Graph Tool toolbar button or selecting Metamodel | Graph Tool in the MetaEdit+ launcher. In the Graph Tool, press the Open button on the toolbar. ‘Family Tree’ should be currently the only graph definition we have and therefore it should be loaded automatically. However, if there are more definitions, choose ‘Family Tree’ from the list that opens.

Go to the Types page in Graph Tool’s tab view. In the Objects list, select ‘Person’, press the right mouse button and select Delete from the pop-up menu. Then press the right mouse button again, select Add... and choose ‘Male’. Add ‘Female’ similarly to get to the state in Figure 5-6.

Graph Tool Types modifications

Figure 5-6. Modifications in Graph types definer.

Go to the Bindings page. Choose the first Parent role from the Roles list. Go to the Objects list, delete ‘Person’ and add ‘Male’ in its place. Similarly, select the second Parent role and replace its Person object with Female. Your Graph Tool should now look similar to Figure 5-7.

Graph Tool Bindings modifications

Figure 5-7. Modifications in Graphs bindings definer.

As for the Child role, leave it connected to the Person object. While Person was actually removed from the type set of our Family Tree modeling language, its references were not and thus we can use it here. Person as their super type allows both Male and Female to be used.

Press Save and Close to accept modifications and close the Graph Tool. The modifications for improving our modeling language have been now made, so you can try it out again. This change was fairly radical (no old object types are in use), and we have only a tiny example model, so there is no point trying to automate the update (it could be done with XML export and import). We’ll remake the model after the next change.

Show in Frame No Frame
Up Previous Next Title Page Contents Search