I am having trouble naming and thus searching for the right keywords for a pattern I am seeing in my web applications and their associated difficulties. Here are some examples of the pattern I mean:
CMS: A page layout can have various regions in which editable elements can be added. Some of these elements might need to be shared across all pages having the layout, so we could pin those elements to the layout. But what about exceptions, what if one page that is using the layout just needs one of the pinned elements to be different, be overwritten with a custom element for them.
Authorization: A user is assigned a set of tasks they are allowed to do. To make it easier to assign the set of tasks, user roles could be used to assign a subset of tasks that belongs to that role. What about some exceptional user, that has a role, but isn't allowed to do one of the tasks of that role.
Both examples share the following:
- There primitives (authorization: tasks, CMS: elements) which are all the system cares about in the end.
- Templates (authorization: user roles, CMS: pinned elements) are just there to make it easier to determine the primitives.
- There is a need to prevent repetition, in theory, similar things can be reproduced by adding the primitives in a similar way, but this would be painful and error-prone.
- To prevent future repetitions, sharing could be used, e.g. in the case of authorization and their user roles, we probably want it to be the case that when a task is added or removed to the user role, this updates all users who have that user role.
The difficulties they share:
- Exceptions to the templates might need to be updated when the template is updated. For example, say you pinned some link element that you later want to make a button element, it is likely that you want your exceptions to this pinned element to now also become a button. In the case of a user role, when a task is added, the user that had one task removed, might now need to also have that newly added task removed as well.
- Using templates only initially to determine the primitives will make them most flexible, but it also sets them in stone, future updates, if big enough, will bring back to the whole situation templates were introduced for.
Another example would be: I have a list of VS Code extensions that I want to share between my personal and work device, though, some of my extensions on my personal device are only needed there, like for some hobby projects. These can be excluded, but what if I later add another extension to my personal device, what happens to the work device? I likely want it to be updated too unless it is again an extension unrelated to work.
In general the problem could be simplified as wanting to prevent having to manually assign items to every set (tasks of a user, elements of a page, extensions of a device), so some kind of reuse is wanted, ideally which includes sharing, such that a strategy can be made for future changes.
Of course, I can think of various solutions and sharing strategies to implement, but I feel like I would be reinventing the wheel and that there should be some documentation or library out there that already has this figured out well.
If someone knows of such documentation or libraries or knows of the kind of keywords I might use to find more about this stuff, I would love to know.