使用一个远程对象和多个目标
在我的 Flex 应用程序中,我使用一个远程对象和多个目标。这是一个坏主意吗?除了一两个边缘情况之外,它似乎工作得很好:
- 这是糟糕的设计,但我们在两个不同的目的地上使用相同的方法名称,并且在同时调用它们时它们似乎会发生冲突。
- 记录错误显示分配给一个目标的方法与另一个目标相关联。
In my Flex app, I use one remote object and multiple destinations. Is that a bad idea? It seems to be working just fine except for the one or two fringe cases:
- It's bad design, but we use the same method name on two different destinations and they seem to conflict when they're called at the same time.
- Logging errors show a method assigned to one destination as being associated with another.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如你所猜测的。由于多种原因,这是一种糟糕的设计:
我的建议是将两个远程对象包装到一个父对象中。您可以传递这个单个对象/类,并且仍然可以访问两个目的地。
或者
如果您预计添加多个功能,请创建一个带有处理远程处理逻辑的方法的单例类。这将使远程访问在整个应用程序中保持一致,并将目标逻辑保留在一处。
As you've guessed. This is bad design for a multitude of reasons:
My suggestion would be to wrap two remote objects into a single parent object. You can pass this single object/class around and still have access to both destinations.
OR
If you're anticipating adding multiple features, create a singleton class with methods for handling remoting logic. This will keep Remoting access consistent across your application and leaves the destination logic contained in one place.