|
-
Oct 1st, 2005, 09:34 AM
#2
Fanatic Member
Re: VB code cleanup
Hi,
The first thing I would do is get rid of the AS keywords, you dont need it and it actually uses memory (sight amount, but still more that you should be using...) and use something like this.
1. dim intVariable
' int signifies to the programmer that it is integer. good practice and makes easier for reading
2. dim intVariable : variable value
' use the colon to assign values to the variable before commening. even if it is a logical boolean operator statemetn, still do it. sves on space and easier to read, and no need to call the valieable again just to assign a simpole form value, variable value, boolean command, test command etc.
3. dim strArray(31)
'if you are using arrays, declare the aray details below the array declaration, makes forf eaiser referenceing and reading. In addition to this, what you could do is you can be arrissed restructureing your code, is use dynamic arrays called by the Scripting model and JIT complier, therewby saving space but the first thing I would do, is decalre the array contents directly below the instancde decalration.
4. public variables.
' really, all these variables should be in a private functions, not an option base, and set all your variables within this framework, not just three of them ( unless very specific circumstances overrules this, but rarely such an occurrence does.) then all your code within functions, subs cal call on them when neeed. It also makes for good housekeeping.
So it should look like this
private function var-declaration
' al variavbles decalred within this
end function
then at the bottom of your code.
private function var_destroy
'all nothing and null declarations set here
end function
you could use classes if you wanted to, this is also a visable option, but requires a good knowledge of VBScript coding to create a new instance, then use it.
with the amount of variables you have, you can get rid of the size of the coding, but you can make it for easier followign reading and parsing for the compiler.
If you follow these guidelines, the applicaiton should actually run faster, as it has less to trawl thorough.
one other thing. It is the best policy for this type of code to be inputted into an asp page, then use a virtual SSI to include it. such like this
<!-- #include virtual="//include/app_code.asp" -->
<doc type blah blah blah>
the code will be given prioroty to toe parser and compiler, and will be instanced into the page before any Transactable objects (HTML, ASP, Javascript, Jscript, ECMA and CGI raw code.) are initiated into the page.
Mkes for very good practice, if not aadvanced page page building.
hope tjhis helps
Kai
As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..
A few things that make a good Developer a Great One.
Methodical and a thorough approach to research and design inevitably leads to success.
Forward thinking is the key to Flow of control.
Never test in the design environment, always test in real time, you get the REAL results.
CBSE & OOSE are the same animal, they just require different techniques, and thinking.
SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
The key to good design is explicit attention to both detail and response.
Think Freely out of the "Box" you're in..... You will soar to better heights.
Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT
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
|