Im trying to figure out if the relationships between each class is correct. Im trying to learn it and get confused between what each should be.
The is the code for each:
package part1;
public enum Role {
STUDENT, ACADEMIC
}
package part1;
import part1.part11.Students;
import part1.part12.AcademicStaffMembers;
public class Controller {
private int id;
public Controller(Role role) {
if(role == Role.ACADEMIC){
AcademicStaffMembers academicStaffMembers=new AcademicStaffMembers();
}
else if(role == Role.STUDENT) {
Students students = new Students();
}
}
}
package part1.part11;
public class Students{
private Student[] students;
}
package part1.part11;
import part2.Module;
import part2.ModuleCode;
public class Student {
private int id;
private Module[] modules;
private ModuleCode[] moduleCodes;
}
package part1.part12;
public class AcademicStaffMembers {
private AcademicStaffMember[] academicStaffMembers;
}
package part1.part12;
import part2.Module;
import part2.ModuleCode;
public class AcademicStaffMember {
private int id;
private Module[] modules;
private ModuleCode[] moduleCodes;
}
package part2;
public class Module{
private ModuleCode moduleCode;
}
package part2;
public enum ModuleCode{
CSC1022, CSC1023, CSC1024, CSC1025, CSC1026, CSC1027, CSC1028, CSC1029, CSC1030, CSC1031
}
Currently I believe the relations are as follows:
Controller:
- Association with Role
- Dependency with Students
- Dependency with AcademicStaffMembers
Students
- Composition with Student (Diamond at Students)
AcademicStaffMembers
- Composition with AcademicStaffMember (Diamond at AcademicStaffMembers)
Student
- Association with Module
- Association with ModuleCode
AcademicStaffMember
- Association with Module
- Association with ModuleCode
Module
- Composition with ModuleCode (Diamond at Module)

Any help or advice would be amazing, thanks you.
Normally, we don't do reviews here.
However, your example is interesting in view of the confusion between transient relationships for the time of an operation and semantic relationships:
The relationship between
ControllerandRoleis transient: it exists only temporarily for the time of an operation, even if the operation is the constructor. It's not an association between classes, but a dependency.This shows by the way a design flaw, since
studentsandacedemicStaffMemberscollections are created during the operation, but cannot be used outside that operation, making them somewhat useless. To make it work, bothStudentsandAdademicStaffMembersshould be singleton classes, or bothstudentsandacedemicStaffMembersshould be made private attributes ofController.It is also interesting for the use of composite aggregation (black diamond) for modelling collections:
0..1on the side of the collection, and*on the elements to be collected, which is far more useful and accurate. Consider using composite aggregation only if strictly needed.Showing multiplicities would also significantly improve the expressiveness of your diagram (for example to clarify that academic staff members can be associated with many modules and many module codes).
Additional advice: The (ab)use of enumeration should raise some questions:
Controller)? If yes, consider specialisation - It makes perfect sense to have aStudentControllerand aAcademicStaffMemberControllerinheriting from a more generalController, since the behaviours, verifications, rules, operations might not be the same for the two.ModuleCode)? If yes, keep them only if the list is supposed to be fixed for a long time. If the list may however change (e.g. new course modules could be introduced every year, like CS1032 for the new VR UX, or CS1033 for Latest developments in LLM AI) then consider moving away from enum and use ModuleCodes as a class with attributes code and title.