[AccessD] Naming Conventions

DWUTKA at marlow.com DWUTKA at marlow.com
Thu Aug 5 16:52:02 CDT 2004


Hiss! <grin>

As for the order of savings between a long integer and an integer:

Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim dtTemp As Date
dtTemp = Now()
For i = 1 To 32000
    For j = 1 To 32000
    Next j
Next i
Me.Label1.Caption = (Now - dtTemp) * 24 * 60 * 60
End Sub

Private Sub Command2_Click()
Dim i As Long
Dim j As Long
Dim dtTemp As Date
dtTemp = Now()
For i = 1 To 32000
    For j = 1 To 32000
    Next j
Next i
Me.Label2.Caption = (Now - dtTemp) * 24 * 60 * 60
End Sub

Produced a little more then 25 seconds for Command1 and just under 21
seconds for Command2.  That would be aproximately 19% faster.  Which isn't
something that should be ignored.  If you look at the speed versus size
issue, are you calculating with the integers more then you are declaring
them? (ie, if you run a for i=1 to 100, are you declaring 99 other integers,
to save at least 400 bytes?)

I then added k (Integer in Command1, and Long Integer in Command2), and
compiled the project into an .exe.  This time, the Integer took just shy of
12 seconds (11.99999) and the Long Integer too just shy of 6 seconds
(5.9999999).  So when compiled, the Long Integer is 100% faster then an
Integer.

I do understand shop constraints, which is why I like not being in a shop.
<grin>

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Thursday, August 05, 2004 3:51 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Naming Conventions


Apparently I'm not making *myself* clear.  

What is the order of savings between the integer and the long in that
loop, and who cares?  Neither is going to be noticeable, but if your
shop standards say you use the smallest possible datatype appropriate
for the operation, then you use an integer for a loop that doesn't
require a long.  I prefer to avoid floating point creep, but a currency
type is larger than a single, so I'm forced by our requirements to use a
single where I would rather not.  However, if I take the approach that
we *always* use singles for this so I don't have to make it obvious, I
am a NAUGHTY developer with a high and mighty attitude because I really
should know that there is no such thing as ALWAYS and other developers
have to be able to read my code without difficulty!!

Charlotte Foust


-----Original Message-----
From: DWUTKA at marlow.com [mailto:DWUTKA at marlow.com] 
Sent: Thursday, August 05, 2004 12:41 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Naming Conventions


Because:

Dim i As Long
Do until i=100
	i=i+1
loop

Runs faster then 

Dim i as Integer
Do Until i=100
	i=i+1
Loop

Why declare a counter with a prefix?  If you are using an integer, for
'smaller' counts, then whether you are using a prefixed variable or not,
you're still missing the point.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Thursday, August 05, 2004 3:19 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Naming Conventions


But you see, I have to rationalize that in order to guess that you've
used a long.  If the loop only requires an integer up to 100, why use a
long "of course"?  If you declared the variable with a prefix or even a
type declaration character, it wouldn't require anyone else to try and
guess what you were thinking.

Charlotte Foust


-----Original Message-----
From: DWUTKA at marlow.com [mailto:DWUTKA at marlow.com] 
Sent: Thursday, August 05, 2004 11:11 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Naming Conventions


Long of course.  Why would you use byte or Integer in a 32 bit
environment? A 32 bit Long Integer will out perform the other two!  In
fact, the only reason to use other numbers, is to confirm with API
calls, when necessary. Other then that, there is no reason to use them.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Thursday, August 05, 2004 1:14 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Naming Conventions


Byte, Integer or Long?  Any of them can be counters.  Counter is a
non-definitive term for a value, and I object to that kind of coding.  

Charlotte Foust


-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com] 
Sent: Thursday, August 05, 2004 8:23 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Naming Conventions


Me too, Drew. In my code, anything named i j or k immediately signals
that's all it is, a counter.

A.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
DWUTKA at marlow.com
Sent: Wednesday, August 04, 2004 5:15 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Naming Conventions


What's wrong with:

For I=1 to 50

Next I

?

Drew

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list