|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is it bad practice to......
Thread for all your questionable programming practices.
I'll start it off by asking: Is it bad practice to start your array at 1 (myarray(1)) leaving the first slot blank? |
|
#2
|
||||
|
||||
|
Quote:
first: why in the world?! second: waste of resources. third: confusing. |
|
#3
|
||||
|
||||
|
is it bad practice to NOT "Dim" all your vars?
at the moment I don't, but have been starting to lately? Shem
__________________
Everyone has a photographic memory. Some don't have film. I am a nobody, nobody is perfect, therefore I am perfect.
|
|
#4
|
||||
|
||||
|
Quote:
why? it can lead to weird error messages that it's headache to debug and track down. you can have typo in variable name and instead of Undefined Variable message you'll get Type Mismatch or even worse. |
|
#5
|
||||
|
||||
|
thanks SW
![]() ![]() Shem |
|
#6
|
||||
|
||||
|
And, in classic ASP at least, include a line <% Option Explicit %> at the top of your code.
This forces all variables to be declared and will error out if there are any that are undeclared, such as typos etc.
__________________
Policy Check I'd rather have a full bottle in front of me, than a full frontal lobotomy...
|
|
#7
|
|||
|
|||
|
Cool, I learned two new things today
![]() |
|
#8
|
|||
|
|||
|
You should use a "house style" for coding.
Every programmer is different but from the posts in the forums you will get a general idea. Code Indentation is up there Syntax case is not as important, but it can still help with code display. e.g. How do you name custom variables/functions? Do you follow the capital letter for next word? Do you use underscores? Syntax in general can be an individual choice. VB (and most other languages) have several methods for the same result. How do you check if a form has been posted? How do you loop? Do or While? I'm a bit of pick and mix. Because i've taught myself from online sites, DW and started in PHP and Javascript then I have many methods and could actually use two different methods in the same script ![]() Luckily I don't work in a big department collaborating onn scripts with other people.
__________________
CyberTechHelp |
|
#9
|
|||
|
|||
|
Quote:
Funny you should mention this. I just posted about coding structure in this thread as it makes debugging much more easier: Debugging Techniques
__________________
jmurrayhead Did I help you out? Make me popular by clicking the icon!New Members:Proper way to post a question Powered by ASP.Net |
|
#10
|
|||
|
|||
|
Good example
![]() |
|
#11
|
||||
|
||||
|
OK, how about whether or not to put spaces between operators and operands, functions, etc.?
myVar4=myVar1+myVar2+substr(myVar3,2,8) myVar4 = myVar1 + myVar2 + substr ( myVar3, 2, 8 ) The second method is arguably easier to read, but does it really matter? |
|
#12
|
|||
|