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?


  1. first abstract the attributes that each role has as the underlying interface
  2. Factory mode is recommended
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35178-2bf94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35178-2bf94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?