473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Public Sub/vars in web app?

I'm new to the web forms world (ASP.Net) but not vb and am converting a
vb6 windows app to the web. If I create public subroutines at a module
level, is this a problem in a server based app? Will my users step on
each other? I'm confused about whether global module level subroutines
and variables are exposed to all users at the same time or if .NET gives
them their own space at runtime.

Also, I'm assuming that creating a class for each subroutine will give
me an instance of the object where it's data is encapsulated thereby
eliminating the above if there is a scope problem. Just looking for
thoughts here.

Thanks.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
3 1493
You need to understand that while the syntax of VB.Net is similar to VB6,
VB.Net is truly object-oriented, whereas VB6 is not. So you have to start
thinking in object-oriented terms. While VB.Net allows you to create
Modules, this is more for backwards-compatibility than it is useful. Modules
are not truly object-oriented, and you really want to leverage the
object-orientation of the .Net platform as much as possible. And modules,
which are never instantiated, will indeed cause the problems you have
mentioned, as everything in a Module is Shared.

You also don't want to create "a class for each subroutine" - rather than
thinking in terms of subroutines, you need to start thinking in terms of
Methods. A Method can be either a Sub or a Function, but it is a member of a
class. A class can have many Methods encapsulated within it. You want to
organize your classes to contain Methods that share something in common,
whether that is data that is global to the class, or functionality. If you
want to create Methods that don't require instantiation, you can create
Shared Methods. Within a class you can have both Shared Methods (which don't
require an instance of a class - similar to subroutines in a module) and
Methods which require an instance of the class. You need to determine which
kind of Methods to create in the class, according to the functionality and
requirements of the Methods.

Learning to leverage the full object-orientation of .Net is a learning
curve, but will empower you in ways you probably haven't yet imagined. Try
to get familiar with concepts of encapsulation, polymorphism, and
inheritance in particular. And familiarize yourself with the various kinds
of additional scope that object-orientation affords. The Microsoft .Net SKD
is a free download from:

http://www.microsoft.com/downloads/d...displaylang=en

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"thdevdex" <th******@dbcoders.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
I'm new to the web forms world (ASP.Net) but not vb and am converting a
vb6 windows app to the web. If I create public subroutines at a module
level, is this a problem in a server based app? Will my users step on
each other? I'm confused about whether global module level subroutines
and variables are exposed to all users at the same time or if .NET gives
them their own space at runtime.

Also, I'm assuming that creating a class for each subroutine will give
me an instance of the object where it's data is encapsulated thereby
eliminating the above if there is a scope problem. Just looking for
thoughts here.

Thanks.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #2
Everything in ASP.NET is going to be wrapped in a class, and any two objects
that share the same instance of an object of this class will share the same
values in variables. If you want to store information specific to a user,
you should use the Session object. If everyone should share the same piece
of information, then you should use the application object. You also have
several additional mechanisms of storing persistent information, such as
ViewState, Cache, and so forth - it really depends on what your needs are as
to what is the best choice for the problem you are trying to solve.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"thdevdex" <th******@dbcoders.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
I'm new to the web forms world (ASP.Net) but not vb and am converting a
vb6 windows app to the web. If I create public subroutines at a module
level, is this a problem in a server based app? Will my users step on
each other? I'm confused about whether global module level subroutines
and variables are exposed to all users at the same time or if .NET gives
them their own space at runtime.

Also, I'm assuming that creating a class for each subroutine will give
me an instance of the object where it's data is encapsulated thereby
eliminating the above if there is a scope problem. Just looking for
thoughts here.

Thanks.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
You need to understand that while the syntax of VB.Net is similar to VB6,
VB.Net is truly object-oriented, whereas VB6 is not. So you have to start
thinking in object-oriented terms. While VB.Net allows you to create
Modules, this is more for backwards-compatibility than it is useful. Modules
are not truly object-oriented, and you really want to leverage the
object-orientation of the .Net platform as much as possible. And modules,
which are never instantiated, will indeed cause the problems you have
mentioned, as everything in a Module is Shared.

You also don't want to create "a class for each subroutine" - rather than
thinking in terms of subroutines, you need to start thinking in terms of
Methods. A Method can be either a Sub or a Function, but it is a member of a
class. A class can have many Methods encapsulated within it. You want to
organize your classes to contain Methods that share something in common,
whether that is data that is global to the class, or functionality. If you
want to create Methods that don't require instantiation, you can create
Shared Methods. Within a class you can have both Shared Methods (which don't
require an instance of a class - similar to subroutines in a module) and
Methods which require an instance of the class. You need to determine which
kind of Methods to create in the class, according to the functionality and
requirements of the Methods.

Learning to leverage the full object-orientation of .Net is a learning
curve, but will empower you in ways you probably haven't yet imagined. Try
to get familiar with concepts of encapsulation, polymorphism, and
inheritance in particular. And familiarize yourself with the various kinds
of additional scope that object-orientation affords. The Microsoft .Net SKD
is a free download from:

http://www.microsoft.com/downloads/d...displaylang=en

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"thdevdex" <th******@dbcoders.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
I'm new to the web forms world (ASP.Net) but not vb and am converting a
vb6 windows app to the web. If I create public subroutines at a module
level, is this a problem in a server based app? Will my users step on
each other? I'm confused about whether global module level subroutines
and variables are exposed to all users at the same time or if .NET gives
them their own space at runtime.

Also, I'm assuming that creating a class for each subroutine will give
me an instance of the object where it's data is encapsulated thereby
eliminating the above if there is a scope problem. Just looking for
thoughts here.

Thanks.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #4

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

Similar topics

0
by: james | last post by:
I am new to php and need some help getting the session variables into include files. (after-thought, Sorry for the drawn out post but I really, really need help....;) Here's what I'm doing.. ...
7
by: Jozef | last post by:
Hello, I have an interface that sets some variables when it starts up. For some reason, when I have an error in the code (wherever it is, even if it isn't related to the variables) the...
3
by: Jon | last post by:
I have a couple of tables I want to load into a dataset and keep around pretty much forever, although they will need to be refreshed every so often. I can either put the dataset into an...
5
by: cFleury | last post by:
Hi, I have a public structure which is initialized only at startup time but at least one of the elements of this structure is losing its value, this particular element is ONLY initialized at the...
3
by: Tor Inge Rislaa | last post by:
How to use a public variable In VB.6.0 I could in the declaration part of a form declare a public variable, then assign a value to the variable, open a new form and address the variable and read...
4
by: Dennis | last post by:
I have read and re-read VB.Net's help on scope of variables but darned if I can understand the difference between Friend and Public variables? -- Dennis in Houston
2
by: Darrel | last post by:
I'm working on an app where the ASPX pages aren't precompiled with the class.vb files I'm. This is so people can add their own ASPX pages down the road to the app (the .aspx pages become...
7
by: robert.waters | last post by:
Why do my public variables (including class instances) disappear when my app experiences an unhandled error? My custom class module's class_terminate event doesn't even fire, the instance just...
19
RMWChaos
by: RMWChaos | last post by:
Previously, I had used independent JSON lists in my code, where the lists were part of separate scripts. Because this method did not support reuse of a script without modification, I decided to...
5
by: Ross | last post by:
Forgive my newbieness - I want to refer to some variables and indirectly alter them. Not sure if this is as easy in Python as it is in C. Say I have three vars: oats, corn, barley I add them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.