[英]Hiding methods from the GUI
I am implementing the observer pattern in java to separate my model classes from the GUI. 我正在用Java实现观察者模式,以将模型类与GUI分开。 The problem is that, every time the update-method is called, the model-instance is given as a parameter.
问题在于,每次调用update-method时,都会将model-instance作为参数给出。 That means, the GUI can call methods on the model-objects which should not be called from the GUI.
这意味着,GUI可以在模型对象上调用不应从GUI调用的方法。 How to avoid that the GUI can manipulate the model objects?
如何避免GUI可以操纵模型对象?
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. 为了实现这一点,您需要引入另一层,它将使用一个模型对象并将其转换为DTO并返回到GUI,反之亦然。 Kind of Data access design pattern used in many projects.
在许多项目中使用的一种数据访问设计模式。
For more information visit this link 有关更多信息, 请访问此链接
Hope this gives you the idea. 希望这能给您这个想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.