Discussion: I’m feeling the following Admin class described as example could be a God Class, since if we add operations requires admin in future, we need to put everything into the Admin class regardless of entities/use-cases.
I feel that violates the single responsibility principle. What do you think?
public class Admin extends Account {
// spot here refers to an instance of the ParkingSpot class
public boolean addParkingSpot(ParkingSpot spot);
// displayBoard here refers to an instance of the DisplayBoard class
public boolean addDisplayBoard(DisplayBoard displayBoard);
// entrance here refers to an instance of the Entrance class
public boolean addEntrance(Entrance entrance);
// exit here refers to an instance of the Exit class
public boolean addExit(Exit exit;
// Will implement the functionality in this class
public boolean resetPassword() {
// definition
}
}
An alternative idea I come up with was:
-
Rather than put those methods in the Admin class, we can create collection classes for DisplayBoard, Entrance, Exit, and ParkingSpot and implement those methods into the above classes.
-
We can create a Facade that checks the caller’s principle when invoking those methods.
I’m feeling this can be too detailed in a job interview.
I’m glad if you give me some feedback.