立面设计问题
我有以下问题:
在包 A(一个单独的 dll)中,我有 ClassA。
在 Facade (另一个单独的 dll)中,我有一个方法 public IEnumerable GetAll(){}。
在Web应用程序中,我调用Facade.GetAll(),但为了获取IEnumerable,我需要引用Facade和包A。
我想知道是否可以仅引用Facade,同时获取IEnumerable(例如为ClassA构造接口)在门面或 类似的东西)?
否则,如果我引用这两个 dll,我可以从 ClassA 调用 GetAll()(理论上或错误地)。但最初的想法是通过外观与业务类进行通信,这样像网站这样的最终应用程序就不会知道业务类的存在?
I have the following question:
In package A (a separate dll) I have ClassA.
In Facade (another separate dll) I have a method public IEnumerable GetAll(){}.
In web application I call Facade.GetAll(), but in order to get IEnumerable I need to reference both Facade and package A.
I wonder if it's possible to reference only Facade and at the same time get IEnumerable (for examle constructing interface for ClassA in facade or
something like that)?
Otherwise if I reference both dlls I can call GetAll() from ClassA (theoretically or by mistake). But the initial idea was to communicate with business classes through the facade so the end app like website would not know about existence of business classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决此问题的一般方法是使用包含接口的包,该接口由
1. 您的实施(A 类)
2. 你的外观(或代理或任何你有的替代品)
3. 使用它的应用程序或类。
这样你就永远不会使用错误的实现。而且你更加独立于具体的类。
A general approach for this issue is to use a package containing an interface, shared by
1. Your implementation (ClassA)
2. Your Facade (or proxy or whatever replacement you have)
3. the application or class using it.
This way you can never end up using the wrong implementation. And you are more independent of the concrete classes.