Results 1 to 10 of 10

Thread: [RESOLVED] DLL - Class or Module?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Resolved [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

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [RESOLVED] DLL - Class or Module?

    Oops, read it wrong. TG is right, a module is simply a VBism.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [RESOLVED] DLL - Class or Module?

    Yeah, I pretty much read it completely wrong!

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [RESOLVED] DLL - Class or Module?

    Combination of work and tiredness actually!

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DLL - Class or Module?

    Quote Originally Posted by techgnome View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width