|
-
Aug 5th, 2010, 11:34 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] DLL - Class or Module?
What's up?
I am creating a couple of DLLs and was wondering on what others' opinions were.
I used to create DLLs with classes. I just made one with a module, works well.
It actually seems to be the best choice if the DLL is going to encapsulate functions and not really relate to any one specific thing (object).
If you use a module you don't have to instantiate it. Making a class and marking every public method static seems silly, no?
Any opinions?
Last edited by MarMan; Aug 5th, 2010 at 11:35 AM.
Reason: missed a word
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Aug 5th, 2010, 11:51 AM
#2
Re: DLL - Class or Module?
Making a class and marking every public method static seems silly, no?
No, not really... because 1) that's what's going on behind the scenes anyways... 2) the concept of a module is VB-specific... C# doesn't have anything like it (short of doing it all by hand). So in general terms of learning OOD/OOP ... no, it doesn't seem silly, but logical. The use of a module file simply takes the mundane out of having to do it yourself.
-tg
-
Aug 5th, 2010, 12:05 PM
#3
Thread Starter
Frenzied Member
Re: DLL - Class or Module?
So tech, you think it makes absolutely no difference whether a module or a class with all its membres static is used? Or is it better to use the class since that is what it really is anyway?
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Aug 5th, 2010, 12:10 PM
#4
Re: DLL - Class or Module?
It makes no difference. If I remember right, the MSIL that's generated during compiling results in the same thing. I just use a class because I'm usually refactoring from an object into a static library, so I'm starting with a class in the first place. And those few times when I know I'm working with static functions, my initial instinct is a class anyways, I rarely give modules a second thought.
In short, it doesn't matter either way, and there is nothing wrong with modules.
-tg
-
Aug 5th, 2010, 03:31 PM
#5
Frenzied Member
Re: [RESOLVED] DLL - Class or Module?
Oops, read it wrong. TG is right, a module is simply a VBism.
-
Aug 5th, 2010, 03:37 PM
#6
Re: [RESOLVED] DLL - Class or Module?
huh? you said that they are the same but not interchangable? Eh? You lost me. A module is in short a static class with static members... right, you can have only one instance of either kind (and I'd even argue the use of instance, but that's another subject)...
If I've got Module X... it is static, as is all of its members. If I have Class Y, declare it static and all of its member static... what's the difference? Nothing... they are essentially the same. No difference. What is different is a class (non-static) that has all static members... now, it's not quite the same, as that class could be instanciated (except then there isn't a reason to, since all of its members are static, any use of them will result in an error.)
-tg
-
Aug 5th, 2010, 03:57 PM
#7
Frenzied Member
Re: [RESOLVED] DLL - Class or Module?
Yeah, I pretty much read it completely wrong!
-
Aug 5th, 2010, 03:59 PM
#8
Re: [RESOLVED] DLL - Class or Module?
OK... just checking... didn't know if you were smoking something, or knew something I didn't... figured either one was a plausible circumstance.
-
Aug 5th, 2010, 04:01 PM
#9
Frenzied Member
Re: [RESOLVED] DLL - Class or Module?
Combination of work and tiredness actually!
-
Aug 7th, 2010, 11:57 PM
#10
Re: DLL - Class or Module?
 Originally Posted by techgnome
the concept of a module is VB-specific... C# doesn't have anything like it (short of doing it all by hand).
A VB module is equivalent to a C# static class. If you declare a class static in C# then declaring a non-static member will produce a compilation error. The two compile to the same IL. The module concept in VB is in keeping with VB6 modules.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|