vendredi 23 décembre 2016

User roles in Java

I am building POS system. The think is that I don't know what roles are going to be with what functionality. Here is what I have till now:

  • I imagined that I have one main class for javafx primary stage, scene and tabpane. Also, there is each class which extends Tab class for tabPane, and all needed code for that functionality. So each tab is separate.
  • On other hand. There is User class which is abstract with basic attributes and abstract method tasks(), and in each concrete user role ( Administrator ) class which extends this abstract class implement this method. In tasks() method I would add in List all tabs class which are needed for that user role.

I want to know if this method for users role is good or bad. Acctualy I am not satisfied. The reason is open-closed OOP principle. I am not sure which users role are going to be, so I want to make it dynamic.

  • Now, what I have in mind, is that I have only one user for start, and that is Administrator. Then, he and only he can make other user roles and save to database. User role tabs he need, administrator would add while creating user role. This way, you can return and add some new functionality to user role. There is no need to go back to code, and adding new to tasks() method.

My concerne is how to implement this. What should I put in database for tasks, should I put Strings and then in some concrete class to add tasks based on string ( With lots of if statement ), or should I serialize arraylist of tasks and then save to database?

Aucun commentaire:

Enregistrer un commentaire