473,804 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Feb 9 '07 #1
173 5740
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...

Feb 9 '07 #2
"Zytan" <zy**********@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.
http://groups.google.com/groups/sear...ject%3Amodule*
Armin

Feb 9 '07 #3
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

Feb 9 '07 #4
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

Feb 9 '07 #5
Any recommendations ?
>From an MVP (Cor):
http://groups.google.com/group/micro...fa6556bc656471
"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

Feb 9 '07 #6
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.

Feb 9 '07 #7
"Zytan" <zy**********@y ahoo.comschrieb :
>Any recommendations ?
>>From an MVP (Cor):
http://groups.google.com/group/micro...fa6556bc656471
"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/>

Feb 9 '07 #8
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" <zy**********@y ahoo.comwrote in message
news:11******** **************@ l53g2000cwa.goo glegroups.com.. .
>Any recommendations ?
>>From an MVP (Cor):
http://groups.google.com/group/micro...fa6556bc656471
"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

Feb 9 '07 #9
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

Feb 9 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1599
by: Brad Tilley | last post by:
I don't understand classes very well... maybe some day. Is it just me or are they supposed to be difficult to understand? They make my head hurt. Anyway, because I don't understand classes well, I avoid using them. However, many modules in the standard library are implemented as classes: sgmllib, HTMLParser, etc. Is it possible to use these modules without getting into OO programming and inheritance and all the other lofty, theoretical...
8
1644
by: Rob Snyder | last post by:
Greetings - I have a situation where I need to be able to have a Python function that will take all the modules in a given directory and find all the classes defined in these modules by name. Ultimately, I would need to loop through all of these, instantiating each of the classes in turn and calling a pre-known method of each. Finding the name of each module is not a problem, but loading the classes out the module once I know the name...
3
2571
by: Javi | last post by:
I have some doubts about what is the best method to distribute classes in .cpp and .h files: - Should I use a file per class? or should I group similar classes in one file? - Is it good to put a lot of class declarations in the same .h, and their definitions in different .cpps? - And, to the contrary, many definitions in one cpp and declarations in different .h? - How to deal with precompiled headers? is it ok to include all headers in the...
8
31901
by: JackRazz | last post by:
Is it possible to create a static class in vb.net like c# does? I want the code to create a single global instance of a class that is inherited from another class. I could use a module, but I can't inherit from a class with it. How would 'public static class classname' be different from just creating a class with all the properties being static? Thanks - JackRazz
5
11617
by: Erik Cruz | last post by:
Hello! I have read some threads discussing the fact that a module is in reality a shared class. If I try to create a Public Shared Class in vb.net I receive a compile error. Why? If I can't explicitly create a shared class, how does vb.net creates it? TIA, Erik Cruz
11
1484
by: John Salerno | last post by:
From my brief experience with C#, I learned that it was pretty standard practice to put each class in a separate file. I assume this is a benefit of a compiled language that the files can then be grouped together. What I'm wondering is how is this normally handled in Python? Is it normal for classes to be put in separate modules? It seems like this can get out of hand, since modules are separate from one another and not compiled...
16
2385
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one or another (could also be 3) different web servers to use these Web Services. The Web Services are identical on all the machines. I tried just changing the URL of the Web Services and cannot make it work. I then decided to create 2 identical web...
5
1661
by: Alex | last post by:
Hi, this is my first mail to the list so please correct me if Ive done anything wrong. What Im trying to figure out is a good way to organise my code. One class per .py file is a system I like, keeps stuff apart. If I do that, I usually name the .py file to the same as the class in it. File: Foo.py *********************** class Foo:
12
2102
by: Janaka Perera | last post by:
Hi All, We have done a object oriented design for a system which will create a class multiply inherited by around 1000 small and medium sized classes. I would be greatful if you can help me with the following: Can this create any problems with GNU g++ compilation, linking etc? What would be the impact to the performance of the system? Anything else we have to consider?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.