Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Lines of Code
#20
(01-21-2025, 03:17 PM)SpriggsySpriggs Wrote: Minimizing lines is good in only a couple of ways, for me:

Code: (Select All)
Dim As Long a: a = 5

You don't need two lines for that. The above crudely emulates how other languages allow you to assign a value during the definition.


Code: (Select All)
If thing = 1 Then DoThing()

Rather than:
Code: (Select All)
If thing = 1 Then
DoThing()
End If
I would like to make the following correction to the code that was set forth earlier:


Code: (Select All)

If thing = 1 Then
    If 1 = thing Then
        If thing = thing Then
            If 1 = 1 Then
                DoThing ()
            End If
        End If
    End If
End If


You cannot assume that values are correct without testing their commutative properties by comparing them in reverse:
   if thing=1 then 1=thing

You also cannot assume that a value equals itself without testing the reflexive property of equality:
   if thing=thing then thing=thing        -and-       if 1=1 then 1=1

And now, and ONLY now can you assume properly that thing=1 and call DoThing()

You are welcome...
Dano
Reply


Messages In This Thread
[split] Lines of Code - by bplus - 01-20-2025, 05:13 PM
RE: [split] Lines of Code - by bplus - 01-20-2025, 11:05 PM
RE: [split] Lines of Code - by SpriggsySpriggs - 01-21-2025, 03:02 AM
RE: [split] Lines of Code - by Pete - 01-21-2025, 07:34 AM
RE: [split] Lines of Code - by mdijkens - 01-21-2025, 10:07 AM
RE: [split] Lines of Code - by SMcNeill - 01-21-2025, 02:37 PM
RE: [split] Lines of Code - by mdijkens - 01-21-2025, 03:04 PM
RE: [split] Lines of Code - by SpriggsySpriggs - 01-21-2025, 03:17 PM
RE: [split] Lines of Code - by dano - 01-25-2025, 04:08 PM
RE: [split] Lines of Code - by Pete - 01-21-2025, 04:26 PM
RE: [split] Lines of Code - by Jack002 - 01-22-2025, 03:19 AM
RE: [split] Lines of Code - by bplus - 01-22-2025, 12:10 PM
RE: [split] Lines of Code - by Pete - 01-25-2025, 05:11 PM



Users browsing this thread: 1 Guest(s)