google-code-export / umple

Automatically exported from code.google.com/p/umple
1 stars 0 forks source link

Hardcode parent attributes in subclasses #553

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Following code will produce warning 44 since the attributes are duplicated and 
the generated constructor in Father still has 3 parameters.

class People {
  sex;
  int age;
  name;
}

class Father {
  isA People;
  age = "M";
}

Another possible way for the same intention is using before constructor:

class Father {
  isA People;
  before constructor{
    super("M", age, name);
  }
}

However, it will generate two super constructor callings.

What is the expected output? What do you see instead?

Constructor of Father should be like this:
public Father(int age, String name){
  super("M", age, name);
}

Umple-Dev Discussion: 
https://groups.google.com/forum/#!topic/umple-dev/u_VR9NkCn1Q

Original issue reported on code.google.com by ckchan.cs on 8 May 2014 at 1:17

GoogleCodeExporter commented 9 years ago
This may need a little more analysis, but certainly, the ability to change in a 
subclass whether a given attribute appears in the constructor may well be 
needed.

Original comment by TimothyCLethbridge on 12 May 2014 at 5:54

GoogleCodeExporter commented 9 years ago
The example of father and people (which should be Person) is terrible 
modelling, so don't use this as the test case. Instead use something like this:

class Vehicle {
  modelName;
  Integer numWheels;
  Boolean hasWheels;
  Boolean isAmphibious;
}

class WheeledVehicle {
  isA Vehicle;
  hasWheels = true;
  [numWheels > 0]
}

class Car {
  isA WheeledVehicle;
  numWheels = 4;
  isAmphibious = false;
}  

Original comment by TimothyCLethbridge on 5 Aug 2014 at 6:50