there is a class that has a lot of properties. Now I have a lot of other roles. Different roles use different fields. What design pattern do you use?
there is a class that has a lot of properties. Now I have a lot of other roles. Different roles use different fields. What design pattern do you use?
isn't the first thing that comes to mind in this case is to split the class?
I can't think of any design pattern for the time being. If I don't limit the design pattern, I have an idea:
write an annotation that defines all roles (names, class names) that can access this field
When accesses, the role base class (if not, access the unit of the class property to do this) scans the properties that the role can access (you can cache fields
first), and then use it as you like.
it's not clear what your means by using , is it a way to read the field values used by different roles or what?
Previous: How to read the source code?
Next: Django reset password