Suppose I have two classes that look like this:
public class Human {
private String name;
private String id;
private List<Bike> bikes;
}
public class Bike {
private String model;
private String id;
private String type;
}
Now, is it worth putting String humanIDinto a classroom bike? I can do almost any operation with the current structure, but if, for example, I get a bike object and want to know its owner, I need to iterate over a collection of people. On the other hand, if I put the humanID inside the bike, I feel that it will be curious redundant information, because the agregation itself says who the owner is. So can someone explain which one is the right approach and why?
source
share