Classes vs. Modules

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zytan

    #1

    Classes vs. Modules

    I've read the docs on this, but one thing was left unclear. It seems
    as though a Module does not have to be fully qualified. Is this the
    case? I have source that apparently shows this.

    Are modules left-over from VB6, and not much used anymore? It seems
    that it is better to require Imports or use fully qualified names for
    functions in other classes/modules, but a Module doesn't require this,
    cluttering the global namespace. It seems using a class with shared
    functions/subs is better.

    Any recommendations ?

    Zytan

  • lord.zoltar@gmail.com

    #2
    Re: Classes vs. Modules

    On Feb 9, 3:15 pm, "Zytan" <zytanlith...@y ahoo.comwrote:
    I've read the docs on this, but one thing was left unclear. It seems
    as though a Module does not have to be fully qualified. Is this the
    case? I have source that apparently shows this.
    >
    Are modules left-over from VB6, and not much used anymore? It seems
    that it is better to require Imports or use fully qualified names for
    functions in other classes/modules, but a Module doesn't require this,
    cluttering the global namespace. It seems using a class with shared
    functions/subs is better.
    >
    Any recommendations ?
    >
    Zytan
    I still sometimes use modules for global variables and functions... I
    think it was mentioned a while ago in this group (search for it, I'm
    not sure) that Modules actually get compiled into static classes with
    shared static members and functions...

    Comment

    • Armin Zingler

      #3
      Re: Classes vs. Modules

      "Zytan" <zytanlithium@y ahoo.comschrieb
      I've read the docs on this, but one thing was left unclear. It
      seems as though a Module does not have to be fully qualified. Is
      this the case? I have source that apparently shows this.
      >
      Are modules left-over from VB6, and not much used anymore? It seems
      that it is better to require Imports or use fully qualified names
      for functions in other classes/modules, but a Module doesn't require
      this, cluttering the global namespace. It seems using a class with
      shared functions/subs is better.
      >
      Any recommendations ?
      It's been discussed about 1 mio times, so please search this group first.



      Armin

      Comment

      • Zytan

        #4
        Re: Classes vs. Modules

        I still sometimes use modules for global variables and functions... I
        think it was mentioned a while ago in this group (search for it, I'm
        not sure) that Modules actually get compiled into static classes with
        shared static members and functions...
        Ok. That's interesting.

        I try to avoid global vars like the plague, as do most, so I cannot
        see why anyone would still want to use this. If you're gonna have a
        'global var', it seems better to at least be in a class, where you
        confine it to a certain location.

        Zytan

        Comment

        • Zytan

          #5
          Re: Classes vs. Modules

          It's been discussed about 1 mio times, so please search this group first.http://groups.google.com/groups/sear...3Amicrosoft.pu...
          >
          Armin
          Will do. I'm surprised a generic google search didn't return these
          results, it usually does at the bottom of the first page of results.
          Maybe it's the personalized results stopping it.

          Zytan

          Comment

          • Zytan

            #6
            Re: Classes vs. Modules

            Any recommendations ?
            >From an MVP (Cor):

            "There is never a reason to use a module execpt if you have that
            already in
            your VB6 converted program."

            Exactly what I thought. Good enough.

            Zytan

            Comment

            • lord.zoltar@gmail.com

              #7
              Re: Classes vs. Modules

              On Feb 9, 4:17 pm, "Zytan" <zytanlith...@y ahoo.comwrote:
              I still sometimes use modules for global variables and functions... I
              think it was mentioned a while ago in this group (search for it, I'm
              not sure) that Modules actually get compiled into static classes with
              shared static members and functions...
              >
              Ok. That's interesting.
              >
              I try to avoid global vars like the plague, as do most, so I cannot
              see why anyone would still want to use this. If you're gonna have a
              'global var', it seems better to at least be in a class, where you
              confine it to a certain location.
              >
              Zytan
              I know... I don't like globals either, but they do creep up
              occasionally... I rarely have need for more than one or two. I used
              modules a bit more when porting an old VB6 project. It was just easier
              to leave stuff in them as long as it compiled. those parts are slowly
              being re-written.
              I also like Modules for situations like the Math class. I never need
              to create an instance of Math, I just need functions like sine,
              cosine, and constants, like Pi.

              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Classes vs. Modules

                "Zytan" <zytanlithium@y ahoo.comschrieb :
                >Any recommendations ?
                >
                >>From an MVP (Cor):

                "There is never a reason to use a module execpt if you have that
                already in
                your VB6 converted program."
                >
                Exactly what I thought. Good enough.
                Well, I have to disagree.

                Personally, I do /not/ use modules to store variables and program state. I
                use modules only in very few cases: The project's main entry point is
                placed in a module 'Program'. In addition, common functions are placed in
                modules if their use makes sense throughout the project, similar to
                "Microsoft.Visu alBasic.dll" and its modules. In this case modules are used
                to structure a huge set of functions, but make them easily accessible in
                IntelliSense everywhere.

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                Comment

                • Scott M.

                  #9
                  Re: Classes vs. Modules

                  I don't know if I agree with that. A module can be used as a starting point
                  for your application along with a Sub Main. This can be helpful in
                  directing the flow of the application startup.


                  "Zytan" <zytanlithium@y ahoo.comwrote in message
                  news:1171056218 .903483.221050@ l53g2000cwa.goo glegroups.com.. .
                  >Any recommendations ?
                  >
                  >>From an MVP (Cor):

                  "There is never a reason to use a module execpt if you have that
                  already in
                  your VB6 converted program."
                  >
                  Exactly what I thought. Good enough.
                  >
                  Zytan
                  >

                  Comment

                  • Zytan

                    #10
                    Re: Classes vs. Modules

                    I know... I don't like globals either, but they do creep up
                    occasionally... I rarely have need for more than one or two. I used
                    modules a bit more when porting an old VB6 project. It was just easier
                    to leave stuff in them as long as it compiled. those parts are slowly
                    being re-written.
                    Yeah, understood. I agree. For VB6, it's best to leave as is, until
                    you have time to rewrite. But, this isn't a good starting point to
                    judge how new code should be (and I don't think this is what you are
                    trying to say, so I think we agree).
                    I also like Modules for situations like the Math class. I never need
                    to create an instance of Math, I just need functions like sine,
                    cosine, and constants, like Pi.
                    Yes, exactly. This is precisely what I want. But... it appears you
                    can just call these function without requiring Math.Pi, but just by
                    saying Pi. I don't like this. (Maybe I am wrong about this? But,
                    that's what the docs imply and source code examples I've seen imply.)

                    Zytan

                    Comment

                    • Zytan

                      #11
                      Re: Classes vs. Modules

                      Personally, I do /not/ use modules to store variables and program state. I
                      use modules only in very few cases: The project's main entry point is
                      placed in a module 'Program'. In addition, common functions are placed in
                      modules if their use makes sense throughout the project, similar to
                      "Microsoft.Visu alBasic.dll" and its modules. In this case modules are used
                      to structure a huge set of functions, but make them easily accessible in
                      IntelliSense everywhere.
                      Understood. Thanks. I guess I'm paranoid about having things
                      floating around, so I want them under something, say Math.Pi instead
                      of just Pi.

                      Zytan.

                      Comment

                      • Zytan

                        #12
                        Re: Classes vs. Modules

                        I don't know if I agree with that. A module can be used as a starting point
                        for your application along with a Sub Main. This can be helpful in
                        directing the flow of the application startup.
                        Thanks for your input, Scott.

                        Zytan


                        Comment

                        • aaron.kempf@gmail.com

                          #13
                          Re: Classes vs. Modules

                          modules are PRACTICAL and classes do not allow code-reuse.

                          don't listen to these dipshits around here;80% of VB6 develoeprs NEVER
                          WROTE A CLASS

                          now WHO IN THE FUCK AUTHROIZED MICRSOFT TO FORCE A FEATURE UPON US
                          THAT WE DO NOT USE?

                          my class-less code runs faster than any crap you guys 'write'

                          -Aaron

                          Comment

                          • aaron.kempf@gmail.com

                            #14
                            Re: Classes vs. Modules

                            uh use a module so that you can reuse a method in a class?

                            it's called CODE REUSE

                            not everything fits into a class

                            -Aaron


                            Comment

                            • aaron.kempf@gmail.com

                              #15
                              Re: Classes vs. Modules

                              uh
                              more likely 'THERE IS NEVER A REASON TO USE A _CLASS_'

                              VB IS DEAD
                              AND NO ONE CARES

                              IF THERE WAS A HELL
                              I WOULD SEND MICROSOFT THERE

                              fuck them for killing our language

                              fuck that mother fucking company and all the gooks and chinks that
                              work there

                              -Aaron

                              Comment

                              Working...