I am trying to create chat app that will have different users:simple user, vip users and etcetera.
all types of users will have the data that simple user have, like:name,password,email and so on however all the other users type have uniqe options only to them.
I thought to create class SimpleUser that will have the basic functionality that achieved by using private variables, getters/setters,and so on, while all other user types will have their own classes that extends the SimpleUser class and add their uniqe functionality.
but after I seen this article Do subclasses inherit private fields? its just doesn't seems the right approach.
I am not sure that using Interface to provide optional functionality will help, because i still have private variabels in each user type that I access using getters/setters.
also currently I am cheking in every screen what the type of the user (in order to choose the rigth options for him), its seems clunky, is there a way to check the type of the user only once (when the user logs in) and in all screens simply use his uniqe functions?
-
what is the correct way to design my classes?
-
is their one solution for both my problems?
Aucun commentaire:
Enregistrer un commentaire