Say I want to implement a work place. There are objects of class Employee and there is also a class WorkArrangement, which is like a box into which the employees submit their desired shifts for the next week. (The manager then empties the box and uses this information to arrange shifts for the next week).
The problem is, that the code in the class Employee doesn’t know the object box (of class WorkArrangement), so I can’t write a method which says “put your next week shifts in the box”. I can send the box object as a parameter to the constructor of Employee, but it looks like a bad design in the sense of OOP.
So, is it a bad design?
If it is, then what is a possible solution?
Sounds more like there’s a
Box(could just be a list) that takesShifts, and anEmployeehas multiple collections ofShifts,desiredShiftsandactualShifts.The
Managerthen looks at each employee’s desired shifts, juggles everything around, and assigns actual shifts to each employee, and/or puts them in a shared structure for use in a company calendar.