I'm new to design patterns so my question can sound bit crazy.
I have a web form with a lot of controls on it. Depending on the permissions User has and form status some of the controls needs to be editable or readonly or hidden and so on.
I was wandering about what design pattern should I implement to sort all this mess?
I was thinking about Chain of Responsibility, so each Link in a chain will be responsible for some logic.
Am I on the right way?
While there are probably many ways to approach your problem, it's hard to recommend anything without more specifics about the use case.
However, it sounds like you might have a wider issue to consider. It's very rarely the case that there is a business need to apply the kind of fine-grained permissions you are talking about. I've often seen developers going overboard on creating incredibly flexible roles/rights authorization systems - but think about the problem from a business point of view. Typically there are a few roles whose needs (rights) change very little over time - and each role is trying to perform different tasks.
Could you solve this problem more simply by introducing a form per role and/or status that is optimized for the task at hand? You may find this is easier to maintain in the long run, and clearer for your users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With