project source design question

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I'm trying to decide where to put some globally accessible declarations for
my project. Say you have several enums, one for message types, one for email
formats, one for import method, etc...things your various programs do. You
obviously will have need to use these enums in the actual class that does
these things, but you from time-to-time need to use them somewhere else.

In that cricumstance, would you create a single Declarations module and put
all your enums and global vars in there or would you put them in their
separate class files as public members?

I kind of like having everything come up in intellisense under a
namespace.declaration.whatever, but realize it may make more structural
sense to put them in the class where they are actually related to the class
function.

Opinions?

Thanks
Jon
 
Jon said:
I'm trying to decide where to put some globally accessible
declarations for my project. Say you have several enums, one for
message types, one for email formats, one for import method,
etc...things your various programs do. You obviously will have need
to use these enums in the actual class that does these things, but
you from time-to-time need to use them somewhere else.

In that cricumstance, would you create a single Declarations module
and put all your enums and global vars in there or would you put
them in their separate class files as public members?

I kind of like having everything come up in intellisense under a
namespace.declaration.whatever, but realize it may make more
structural sense to put them in the class where they are actually
related to the class function.

Opinions?


You can put Enums at top level, i.e. in the project's root namespace:

file "global.vb":

enum myglobalenum1
a
b
end enum

end-of-file

If you want to put them into a sub namespace, you can do this also:

namespace mynamespace
enum myglobalenum1
a
b
end enum
end namespace


Just wanted to show that you neither have to put them into a class nor into
a module.

I don't use "global" variables. I usually put them into a class called "App"
and make them Shared. My personal taste because I think that "global
variables" are properties of the application/instance.


Armin
 
Back
Top