ASP Free Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherASP Free Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 18th, 2007, 01:51 PM
IcoN512 IcoN512 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 186 IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 18 h 44 m
Reputation Power: 30
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?

Reply With Quote
  #2  
Old July 19th, 2007, 02:31 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,946 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 50 m 30 sec
Reputation Power: 2014
Quote:
Originally Posted by IcoN512
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?
yep very bad practice IMO.

first: why in the world?!
second: waste of resources.
third: confusing.

Reply With Quote
  #3  
Old July 19th, 2007, 02:34 AM
shem's Avatar
shem shem is offline
Shemzilla
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Aug 2005
Location: Table View, Cape Town, S.A
Posts: 3,380 shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 17744 Folding Title: Novice Folder
Time spent in forums: 2 Weeks 5 Days 1 h 2 m 42 sec
Reputation Power: 531
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.


Reply With Quote
  #4  
Old July 19th, 2007, 02:42 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,946 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 50 m 30 sec
Reputation Power: 2014
Quote:
Originally Posted by shem
is it bad practice to NOT "Dim" all your vars?
at the moment I don't, but have been starting to lately?

Shem
yep, even worse than leaving first entry of array blank.
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.

Reply With Quote
  #5  
Old July 19th, 2007, 02:59 AM
shem's Avatar
shem shem is offline
Shemzilla
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Aug 2005
Location: Table View, Cape Town, S.A
Posts: 3,380 shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)shem User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 17744 Folding Title: Novice Folder
Time spent in forums: 2 Weeks 5 Days 1 h 2 m 42 sec
Reputation Power: 531
thanks SW

Shem

Reply With Quote
  #6  
Old July 19th, 2007, 04:54 AM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,198 richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1Folding Points: 129373 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 2 Days 1 m 28 sec
Reputation Power: 1227
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.
Comments on this post
Shadow Wizard agrees: yup should have mentioned this myself..
Lauramc agrees: Yup, I do that myself; just to avoid temptation. It also avoids implicit conversions by mistake!
__________________
Policy Check

I'd rather have a full bottle in front of me, than a full frontal lobotomy...

Reply With Quote
  #7  
Old July 20th, 2007, 09:47 AM
IcoN512 IcoN512 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 186 IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level)IcoN512 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 18 h 44 m
Reputation Power: 30
Cool, I learned two new things today

Reply With Quote
  #8  
Old July 27th, 2007, 12:32 PM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
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

Reply With Quote
  #9  
Old July 27th, 2007, 01:26 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Week 11 h 27 m 43 sec
Reputation Power: 1580
Quote:
Originally Posted by degsy
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.


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

Reply With Quote
  #10  
Old August 9th, 2007, 11:33 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
Good example

Reply With Quote
  #11  
Old August 25th, 2007, 03:10 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
Click here for more information.
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,957 don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level)don94403 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 23 h 33 m 52 sec
Reputation Power: 394
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?

Reply With Quote
  #12  
Old August 25th, 2007, 03:22 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)