|
-
Jan 27th, 2007, 01:04 AM
#1
Thread Starter
Lively Member
Programming Practices
I originally learned to program with VB4 using a Sams Publishing "12 Easy Lessons" book. For the most part, I have no real issues except that I'm certain I'm not coding in anything even remotely approaching a "standard" manner.
What I'm starting to wonder about is when to use Subs, Functions and Classes. Just because of the way I learned, I pretty much use Subs exclusively.
For example, in the landscape generator I'm working on, I used mostly Subs and no Classes (except for the Form Class). I have a few Functions. I'm currently writing code to give the user an option other than fBm for creating a random image to use as a height map that involves several iterations of random noise, blurring, scaling, rotating and blending of images.
The app has come way too far to rewrite it for release, which I plan on doing within a week, but as I'm writing this new code, I'm finding that I can do it with Functions as opposed to Subs. And the only reason I'm using Functions is because I can do so without having to create additional global variables of which the app already has in excess of 120. And for some reason, it seems that Functions make the code easier to manage, but that may just be my imagination.
Should I create a Class for these Functions? Is there any advantage to doing so given that I wouldn't be using the code in any other app? It seems to me that for the most part, a Class is something you would create if you wanted to use that code in another app. Or should I be creating a Class for each integral section of the app?
If you're curious, you can see screen shots of the app here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|