I have two classes: Student
and User
. The User
class extends Student
, and both of them implement a common interface, which defines a checkSelf()
method. This method checks if the state of the object is valid and is called before performing updates or insertions in the database.
I insert both students and users in the database, which makes it necessary for this method to be callable from outside the class in both cases. This is why the solution found in this post doesn't seem applicable to my problem. Maybe I missed something though.
Basically, the way things are now, both checkSelf()
methods are public and the one in the User
class calls the one from its parent (Student
) before doing its own checks.
How could I go about solving this so I have clean code?