Skip to the content.

Object Relations

-

Object Relations

Relation Name Verbal Expression
Association Has reference to a
Aggregation Has ownership of a
Composition Has ownership of a
Inheritance Is a
Dependence Uses a

-

Association
(“has-reference-to-a”)

-

Aggregation
“has-a” or “has many”

-

Aggregation (“has-a”)
Example

public class Person {
  private Animal pet;
}

-

Aggregation (“has-many”)
Example 1

public class Person {
  private Animal[] pets;
}

-

Aggregation (“has-many”)
Example 2

public class Person {
  private List<Animal> pets;
}

-

Composition (“has-a”)

-

Composition (“has-a”)
Example

public class Person {

  private GregorianCalendar birthDate;

  public Person(int day, int month, int year) {
    this.birthDate = new GregorianCalendar(year, month, day);
  }
}

-

Dependence
(“uses-a”)

-

Dependence
(“uses-a”)
Example

public class Grader {
  public Character grade(Student student) {
    // ... definition omitted for brevity ...
  }
}

-

Inheritance (“is-a”)

-

Inheritance (“is-a”)
Example

public class Person {
  private String name;
  private Date birthDate;
  public Person(String name, Date birthDate) {
    this.name = name;
    this.birthDate = birthDate;
  } // getters and setter omitted for brevity
}
public class Student extends Person {
  private Character currentGrade;
  public Student(String name, Date birthDate, Character initialGrade) {
    super(name, birthDate);
    this.currentGrade = initialGrade;
  } // getters and setter omitted for brevity
}