This question already has an answer here:
I'm working on a project that requires several different users in the system, all of which have overlapping responsibilities; we've isolated two possible ways of tackling this problem, but we're unsure which of them are the most correct way of going about it.
Option 1: Create a virtual super-class for all the user-classes to inherit from. This super-class will have a boolean field for each of the responsibilities, allowing us to toggle which of the sub-classes have which responsibility.
- One single class for all the sub-classes to inherit from, letting us toggle responsibilities via boolean fields
- It's essentially a god-class, which means it holds too much responsibility
Option 2: Create nineteen (19) interfaces, each representing one of the available responsibilities, and then have each of the user-classes inherit from this pool of interfaces in order to determine their responsibilities.
- It allows us to seperate the concerns into several interfaces
- We'll be in over our heads with interfaces, making it difficult to keep track of
So which is the best way of doing it, or is there perhaps a better way?
To elaborate my question I'm including the graphic below; it showcases the relations between the different parts of the system and the different users.
R means read access and RW means read + write access.
As you can see it's a bit of a mess of interlacing attributes.