[Solved] Examining associated objects in equals() [closed]


While I think it is generally a good idea to avoid basing equality on associations, I would argue that this does not apply in all cases. While it is a good rule of thumb, there are likely a number of cases where this rule breaks completely.

It is entirely dependent on the domain and what it means for two objects to be equal. For example:

If you have a cohort of students, taught by a teacher, you could determine equality by requiring that another cohort must contain the same students be (pair-wise equal) and be taught by the same teacher. In that case, the cohort’s equality is strictly dependent on each of it’s pieces being equal.

2

solved Examining associated objects in equals() [closed]