I am implementing the observer pattern in java to separate my model classes from the GUI. The problem is that, every time the update-method is called, the model-instance is given as a parameter. That means, the GUI can call methods on the model-objects which should not be called from the GUI. How to avoid that the GUI can manipulate the model objects?
In order to achieve that, you need to introduce another layer that will take a model object and convert it into DTO and return to GUI and vice versa. Kind of Data access design pattern used in many projects.
For more information visit this link
Hope this gives you the idea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.