Modules? Classes? Neither?

Nyper

New member
Joined
Oct 28, 2005
Messages
2
Programming Experience
1-3
I am in the process of writing a somewhat simple windows application. The majority of my program is long (many lines of code) subroutines to do simple calculations, changing of text boxes, etc. Is it possible to use several modules to keep track of my code better? For instance, I would like to have a seperate module (or just some other file!) to perform actions to text boxes on my main form when a button is clicked on that form (want form1.vb to call moduleX.vb, and modulex.vb able to change textbox1 on form1.vb).

More details...
The program is for a friend of mine. They play golf all the time, and play several different games (lowball/low total, match play, etc etc). There will often be 20 or more people playing, and multiple games/bets amongst them all. Some days it will take them up to 3 hours after playing just to figure all of their games. My program will allow them to simply enter the course par into a scorecard, then enter all golfers scores, the games they are playing, the bets, and computer.

When somebody clicks "Add Golfer" from Form1, I would like to be able to call a seperate file to perform whatever actions I want to take on Form1. My only reasoning for this is simply the organization of code. When I have many subroutines to be ran on courses, golfers, games, etc, using only form1 and the code-behind isn't very efficient.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,579
Location
Sydney, Australia
Programming Experience
10+
VB.NET is an object-oriented language, and as such all your classes and modules are supposed to represent physical or conceptual objects. The one general exception to this is that you may need to have a single module that is used for global variables and methods that may not belong to any particular object other than the application as a whole. You should generally try to have as few of these miscellaneous members as possible. It's your code and you can write it how you want, but that is how OOP is supposed to be done. You might want to spend a bit more time in the planning stage to try to adhere more closely to OO principles.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,579
Location
Sydney, Australia
Programming Experience
10+
To elaborate, you should have a Golfer class, a Course class, a Hole class, a Game class, etc. and then clicking "Add Golfer" would simply create a New Golfer object, which you could then do with whatever you wanted.
 
Top Bottom