You can use Rename in MDriven Designer to change a model element's name and update selected references to it; it is for modelers maintaining attributes, classes, and association ends used throughout a model.
Rename model elements safely
As a model grows, an element can be referenced in many places, including OCL expressions and ViewModels. Editing an element's name directly changes only that element. References that still use the old name can then produce errors when you reindex the model.
Use Rename when you want MDriven Designer to find the current usages of the name and let you decide which ones to update.
Elements supported
The Rename command works for these model elements:
- Attributes
- Classes
- Association ends
Rename an element
- In MDriven Designer, locate the attribute, class, or association end that you want to rename.
- Right-click the element and select Rename.
- In the Rename dialog, enter the new name.
- Review the listed usages. The dialog shows where the current name is used and identifies the expression type, such as a ViewModel expression or an attribute derive expression.
- Select the check boxes for the usages that should be changed. Leave all usages selected when the new name applies everywhere.
- If you are renaming a persisted element and must retain existing data, select Set former name. See Former Names.
- Select Apply.
- Reindex the model and resolve any remaining errors. Open the affected ViewModels and expressions to confirm that they now use the new name.
Example: rename an attribute used by a ViewModel
Assume the class Invoice has an attribute named Number. A ViewModel expression and an attribute derive expression both refer to Number.
- Right-click
Numberand choose Rename. - Enter
InvoiceNumberas the new name. - In the usage list, keep the ViewModel expression and derive-expression usages selected.
- Select Apply.
- Reindex the model. The references selected in the dialog now use
InvoiceNumber.
If you instead edit Number directly to InvoiceNumber, the expressions can still refer to Number. Reindexing exposes those broken references, which you must then correct individually.
Choose which usages to update
The Rename dialog does not require you to update every listed usage. This is useful when an occurrence of the old text must remain unchanged.
| Selection | Result |
|---|---|
| All relevant usage check boxes selected | Renames the element and updates the selected references. |
| A usage check box cleared | Renames the element but leaves that usage unchanged. Review it after applying the rename; it may be intentionally unchanged or may require manual correction. |
| All usage check boxes cleared | Changes only the element name. This has the same practical risk as editing the name directly: existing references can break. |
Review each listed expression before applying the change. In particular, check expressions that navigate associations from more than one class. A rename should change references to the element you selected, not similarly named elements in a different navigation path.
Keep existing database data with Former Names
Former Names is a property on important model elements that records the previous name. When you select Set former name during Rename, MDriven Designer places the old name in that property.
This matters when the element is stored in a database. During database evolution, the former name lets the database evolution process recognize that a renamed column corresponds to the previous column and move existing data to the new name. Without a former name, a renamed persisted attribute can be treated as a new column, leaving the old data behind.
For example, if a stored attribute changes from BrandOfCar to CarBrand:
- Rename
BrandOfCartoCarBrandwith Set former name selected. - The element records
BrandOfCaras its former name. - Database evolution can move data from the old column to the renamed column.
Use Former Names only when the new element represents the same stored information under a new name. Do not use it when you deliberately replace one concept with another and do not want data carried forward.
Validate after renaming
After every rename:
- Reindex the model.
- Inspect reported errors, especially in ViewModel and derive expressions.
- Open the ViewModels that use the renamed element and confirm that their expressions show the intended name.
- If the element is persisted, confirm that Former Names is set when existing database data must survive the change.
For broad, deliberate model changes that cannot be handled through Rename, you can inspect and alter the model through the model debugger.
