Which one ist the correct model for the following implementation.
class Habitat {
int id;
String name;
}
abstract class Animal {
int id;
String name;
Habitat habitat;
}
class Fish extends Animal {
// Fish Attributes
}
Which one ist the correct model for the following implementation.
class Habitat {
int id;
String name;
}
abstract class Animal {
int id;
String name;
Habitat habitat;
}
class Fish extends Animal {
// Fish Attributes
}
Both would be correct from an implementational view. However, since the Habitat is defined as a property of Animal the top left would be the proper model. The bottom right one would show the inherited association rather than the general one. This would be some special view of the model. Diagrams are always a certain view of the model and (almost) never the full picture of it.
Rather than using a named property you should put a role name along the association and use the dot notation to make it an owned property.
The navigation is just superfluous.