In a big system mvc-based there are views responsible for editing data and views that display that data.
Example: UserManagementView
and UserSelectionView
.
Each subsystem should know whether it needs a data update, after another subsystem has made changes to the same data, in order for its controller to know whether a data update is needed.
My thoughts on this is something like the observer pattern (which is kinda integrated in c#) and all controllers would be listeners and eventually would get notified that data-manipulation occurred.
BindingList<>
for example provides a ListChanged
event. Similarly, an interface can be created for each data-structure and notify the controller about the change. This would add overhead (IMO) and I find this solution difficult to maintain in a big system, also updating data anyways is not a solution.
Which architectural design can help in this kind of scenarios?
The data controller determines the purposes for which and the means by which personal data is processed. So, if your company/organisation decides 'why' and 'how' the personal data should be processed it is the data controller.
The controller is responsible for implementing appropriate technical and organisational measures to ensure and to demonstrate that its processing activities are compliant with the requirements of the GDPR. These measures may include implementing an appropriate privacy policy.
One obligation under the GDPR is the requirement of Controllers and Processors to enter into a legally binding contract when a Controller engages a Processor to process personal data on its behalf.
This question sounds like you are trying to use MVC without the model part. If I've misunderstood, editing your question to include a practical use case (example) may help us understand the context.
In general though, nothing should really be persisted/stored in your controllers. So there should be nothing in the controller that requires 'updating' or 'notifying' (ie: no data). Rather the data should be in a separate 'model' layer which manages all your data. Then the views read from the model layer to grab any data for that view.
For a quick refresher check out the wikipedia page on MVC which has a nice classic MVC flowchart and simple write-up on component interactions.
Let's try to contrive an example for the purpose of understanding this problem.
Let's say I have a list of users in my application. This list might be shown on:
Each of those views will request the data from your model layer and show something on the screen.
Now let's say a change was committed to one user's profile. That would be accomplished via a controller method which does any work necessary to apply some changes to the model.
My understanding is that you want all of those views to update to reflect that change. That means the views need to reload data from the model. It should not be getting this data from the controller itself, even if the controller triggers this reload/refresh - or rather a controller method may facilitate querying from your model layer. The important part is that you aren't maintaining multiple copies of your data in multiple controllers throughout your application. The persistence is centralized in the model layer.
In the case of winforms the model layer may be able to provide something like the mentioned INotifyPropertyChanged interface if your UI components are built to recognize that interface and refresh accordingly. But that is a fairly platform dependent approach.
A more platform/context agnostic approach would be the pub-sub (publish-subscribe) pattern also mentioned already. In this case each controller method that makes a change to the model would also publish a notification of its changes. Any views for that data can be listening and respond to such a notification by refreshing/reloading the view's data from the model layer.
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