Eden-06 / FRaMED-2.0

FRaMED 2.0 is the reimplementation of the Full-fledged Role Modeling EDitor allowing the graphical specification of Role-based Software Systems by means of compartments (aka. contexts), objects, roles, and relationships.
Eclipse Public License 2.0
3 stars 0 forks source link

more staticly coded references to container elements in role group #13

Open SriousTaken opened 6 years ago

SriousTaken commented 6 years ago

In the move operation of the role group pattern some code is marked by a TODO comment. This code staticly references container elements checking the type of the element to move using code like "... .getChildren().get(2)". This should be changed to code that searches dynamicly for type body of the element to move (using the shape_id property)!

SriousTaken commented 4 years ago

Equivalent to Issue #1

Example: Bad code in class DataTypePattern, operation move:

ContainerShape dropShadowShape = (ContainerShape) ((ContainerShape) typeBodyShape).getContainer().getChildren().get(0);

Explanation: The executed casts are checked before the displayed code here. Ignoring these, typeBodyShape.getContainer().getChildren().get(0); should not be used as the code .get(0) assumes the children to get is the first one. However this can not be ensured for the lifetime of the software. Instead there should be a for-loop to search over all getContainer().getChildren() for a specific Id. See the good example for reference.

Example: Good solution in class DataTypePattern, operation update:

for(Shape shape : containerShape.getChildren()) {
   ...
   if(UIUtil.isShape_IdValue(shape, literals.SHAPE_ID_DATATYPE_NAME)) {
      text.setValue(businessTypeName);
      returnValue = true;
}   }