Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
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?
Posted

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.
 
Share this answer
 
Comments
Sander Rossel 3-May-11 14:11pm    
Not sure if I want to reuse everything, anything or just small parts yet. But I want to be safe for the future. And putting everything in different DLL's now could save me a whole lot of trouble in the future. So I was thinking of seperating Interfaces and BaseClasses from ConcreteClasses and seperating business logic from UI. The Enum is the only thing that really bothers me. It is not logic, it is not abstract and it is not UI...
Olivier Levrey 4-May-11 8:20am    
I agree. 5.
Just keep the enum with the class or interface which is using them. It doesn't make sense to separate the enum.
Sander Rossel 4-May-11 13:02pm    
Well, if three people are saying it... ;p
My 5 for the answer.
@Naerling - ... It is not logic, it is not abstract and it is not UI...


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
 
Share this answer
 
Comments
Olivier Levrey 4-May-11 8:19am    
I agree. 5.
Hemant__Sharma 4-May-11 9:48am    
Thanks Olivier.
Sander Rossel 4-May-11 12:59pm    
Well, you do certainly have a point there. So, of the example in my original post I should still go with the first... http://i25.servimg.com/u/f25/12/75/88/13/dllsen10.png That one.
Thanks for the answer. 5 from me too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900