Posts: 772
Threads: 35
Joined: Apr 2022
Reputation:
51
Yesterday, 03:02 AM
(This post was last modified: Yesterday, 03:02 AM by SpriggsySpriggs.)
I ain't reading everything in this thread but my two cents is that LOC is the Least Of my Concerns. Get the product working and get it working well. Who gives a shit how long the source is.
The noticing will continue
Posts: 148
Threads: 14
Joined: Apr 2022
Reputation:
16
When a bit older, I really want to be able to understand my code from a couple of years ago
Sometimes I intentionally put all statements on separate lines to show all separate steps that are done and give them a bit more 'weight' in the sub or function:
Code: (Select All)
if order% = _TRUE then
Input "What do you want to order? ", food$
Else
Print "Goodbye"
End If
Sometimes I put statements on the same line to show they belong together and do some small housekeeping:
Code: (Select All)
if groupsize% < 10 then groupsize% = groupsize% + 1 Else groups% = groups% + 1: groupsize% = 0
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Posts: 148
Threads: 14
Joined: Apr 2022
Reputation:
16
Your code is more efficient and better in what it does.
Still (fully depending on functional view of the code at that place) I would put them on 1 line if managing groups & groupsizes is not the main focus of the function it is in; it might be some less important housekeeping.
Then I would prefer to only occupy one line on my screen
If this was in a function with the main responsibility of managing groups & groupsizes, I would put them on 3 separate lines
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Posts: 772
Threads: 35
Joined: Apr 2022
Reputation:
51
10 hours ago
(This post was last modified: 10 hours ago by SpriggsySpriggs.)
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
The noticing will continue
Posts: 2,344
Threads: 242
Joined: Apr 2022
Reputation:
121
I'm with Spriggsy on the use of IF/THEN blocks. I use them if multiple statements are part of the condition, not just a single statement. I also look at the statement(s) length on the line. Frankly, I'd rather be able to read everything without lateral scrolling. Any good chiropractor will tell you doing it that way is better than developing a bad case of SCROLLIOSIS.
Wait... Ah, Steve. Who was it you asked me to pun to death, yesterday?
Pete