有关DLL和枚举的问题... [英] A question about DLL's and Enums...

查看:160
本文介绍了有关DLL和枚举的问题...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用良好的面向对象设计等制作应用程序.因此,我制作接口,BaseClasses等,将它们放入DLL中,制作一些使用该DLL的业务对象,也将它们放入DLL中并使用那些业务.我的UI中的对象.

现在,在将枚举放入所有这些内容时遇到了一些麻烦.我创建一个接口,该接口定义了一个返回MyEnum的方法.在我的业务层中,我实现接口并返回MyEnum.因此,很明显,业务层使用我的Interface和Enum引用了DLL.现在在我的UI中,我想检查方法是否返回MyEnum.1,MyEnum.2,MyEnum.3等.因此...我的UI必须引用与我的业务层相同的DLL,包括Interface. >
所以我的问题是:我的业务层和UI引用相同的DLL是一件坏事吗?因为我认为(尤其是接口)应该由我的业务层使用,然后我的UI层应该使用我的业务对象,而对这些接口一无所知.

我尝试使其更具视觉效果(我不知道UML,所以请耐心等待).
示例1 [示例2 [

I want to make an application using good Object Oriented Design etc. So I make Interfaces, BaseClasses etc., put them in a DLL, make some Business Objects that use that DLL, put them in a DLL too and use those Business Objects in my UI.

Now I am having some trouble with putting Enums in all of this. I create an Interface which defines a Method which returns MyEnum. In my business layer I implement the Interface and return the MyEnum. So it should be obvious that the business layer references the DLL with my Interface and Enum. Now in my UI I want to check if the Method returns MyEnum.1, MyEnum.2, MyEnum.3 etc. So... My UI will have to reference the same DLL as my business layer, including the Interface.

So my question is: Is it a bad thing that my business layer and my UI reference the same DLL''s? Because I think that (especially Interfaces) should be used by my business layer and then my UI layer should use my business objects, not knowing anything about those Interfaces.

I have tried to make it more visual (I don''t know UML, so bear with me).
Example 1[^]
Example 2[^]

So in example 1 the Enum and Abstract are in a single DLL and both my Business Object and my UI need it. It looks weird and ugly.
In example 2 the Enum is in a different DLL and all depend on it, but it looks better organised to me. However, is it best practice to create a DLL for only a single Enum?

推荐答案

如果您的接口/类依赖于枚举,而ui则依赖于接口/classes/enums,我将枚举放入与接口/类相同的程序集中.这样,您可以在另一个应用程序中重用接口/类及其枚举(如果这样做是目的).

如果您根本不打算进行任何重用,那么我将完全放弃使用单独的程序集,而只是将代码组织到功能文件夹中.
If your interfaces/classes rely on the enums, and the ui relies on the interfaces/classes/enums, I''d put the enums into the same assembly as the interfaces/classes. This way, you can resuse the interfaces/classes and their enums in another app (if that is the aim).

If you''re not planning any reuse at all, I''d forego the use of separate assemblies altogether, and just organize the code into functional folders.


@Naerling - ... It is not logic, it is not abstract and it is not UI...



但这是对象或操作的选项/指示符.例如,应将DialogBoxs类型添加到定义DialogBox类的同一程序集中.同样,当返回DialogBox结果时,它将是DialogBoxResult,即Ok/Cancel等.

因此,我也希望将所有枚举都放在Entities程序集中,即interfaces&类定义程序集.

谢谢,
hemant



But it''s an option/indicator for an object or operation. For example DialogBoxs'' types should be added to the same assembly where DialogBox class are defined. Again when DialogBox result is returned it will be a DialogBoxResult i.e. Ok/Cancel etc.

So i would also prefer to put all enums in Entities assembly i.e. interfaces & class definition assembly.

Thanks,
hemant


这篇关于有关DLL和枚举的问题...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆