私は UML ダイアグラムに不慣れで、それについての本を読んでいます。そこには、次のようなクラス図があります。
そして、それは言う、
The implication of a one to one association is that whenever you create an
instance of one of the classes, you must simultaneously create an instance
of the other, and when you delete one you must delete the other.
私の質問は、本当にこれをしなければならないのでしょうか? これらのいずれかに値として「null」を与えることはできませんか? 例えば、この図のJavaコードは以下のように考えているのですが、Companyアイテムを作成したい場合、引数にnullを与えることができます。私が間違っている?それとも、これは悪いコードか間違ったコードですか?
public class Company{
. . .
private BoardOfDirectors director;
public Company(BoardOfDirectors director){
this.director=director;
}
. . .
}
public class BoardOfDirectors{
. . .
private Company company;
public BoardOfDirectors(Company company){
this.company=company;
}
. . .
}
ありがとうございました。