Re: Coding style
- From: "Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx>
- Date: Fri, 21 Jul 2006 10:53:24 -0600
I've been programming many years now and, in general, I tend to prefer the
longer expressions because they often improve readability with no cost to
performance. However, here, I actually think your longer expression is too
convoluted. In addition, it checks CheckBoxPrimaryYN.Checked property
several times, which could impact performance.
So the comparison would be more fair if your "longer version" looked
something like this:
If Me.CheckBoxPrimaryYN.Checked = False And dr.PrimarySet = 1)
Me.CheckBoxPrimaryYN.Enabled = False
Else
Me.CheckBoxPrimaryYN.Enabled = True
End If
That said, I think I personally would go ahead with your short version. I
find it easier to understand than your long version (although not
necessarily easier to understand than my long version). And it accesses each
variable/property only once, which means that its probably a little more
efficient.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Sergey Zuyev" <SergeyZuyev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FBCFC5BE-9706-4BFB-A6BC-2D5A95B54B0F@xxxxxxxxxxxxxxxx
Hello All
I work at software company and we are having a really big discussion
about
coding styles and it seems that more people
prefer statement 1 to statement2 , which was a big surprise to me. Please
help us with your comments. Thanks
Which way is better way 1 or 2?
1. 'set enable status on CheckboxPrimaryYN
If (Me.CheckBoxPrimaryYN.Checked = True) And (dr.PrimarySet > 0)
Then
Me.CheckBoxPrimaryYN.Enabled = True
Else
If (Me.CheckBoxPrimaryYN.Checked = False) Then
If (dr.PrimarySet = 0) Then
Me.CheckBoxPrimaryYN.Enabled = True
Else
Me.CheckBoxPrimaryYN.Enabled = False
End If
End If
End If
2. 'set enable status on CheckboxPrimaryYN
--
Programmer
.
- Follow-Ups:
- Re: Coding style
- From: Greg
- Re: Coding style
- Prev by Date: Re: Coding style
- Next by Date: Re: Not first class in file
- Previous by thread: Re: Coding style
- Next by thread: Re: Coding style
- Index(es):
Loading