08-15-2022, 10:04 PM
Hi Bartok
I have no great theorical knowledge about "the art of coding"... so I can talk about my ideas and thought on your 2 first examples in the while that you can explaing better to me what it means "beautyfy" a code:
I've used to code as Bplus said... large indipendent block of code that do something with no correlation with the rest of code can be closed in a GOSUB (if it uses global main variables) or in a SUB/FUNCTION (passing global main variables needed by parameters or SHARED) so at the place of [a lot of code 1] you can write SubCode1 and at the place of [a lot of code 2] you can write SubCode2.
What is the difference? You read one row of code at the place of a lot of lines of code... so you can have a easier aspect of the code that gives a more editable and debuggable code.
Talking about the two specific examples that you have posted (the first and the second ones) in the first you have a nested SELECT CASE so the logical flow is clear!
In the second example you have 2 equential SELECT CASE... the code does the same thing until when one of the conditions in the first SELECT CASE is activated AND the flow doesn't come back there after the calling.
to be clearer in the first SELECT CASE of the second example posted, if a condition matches (esc, riavvio, menu) then after activated the linked code the flow mustn't come back there in that SELECT CASE...
PS:
My answer is in english just to be accesible to all QB64 friends of this forum.
I have no great theorical knowledge about "the art of coding"... so I can talk about my ideas and thought on your 2 first examples in the while that you can explaing better to me what it means "beautyfy" a code:
I've used to code as Bplus said... large indipendent block of code that do something with no correlation with the rest of code can be closed in a GOSUB (if it uses global main variables) or in a SUB/FUNCTION (passing global main variables needed by parameters or SHARED) so at the place of [a lot of code 1] you can write SubCode1 and at the place of [a lot of code 2] you can write SubCode2.
What is the difference? You read one row of code at the place of a lot of lines of code... so you can have a easier aspect of the code that gives a more editable and debuggable code.
Talking about the two specific examples that you have posted (the first and the second ones) in the first you have a nested SELECT CASE so the logical flow is clear!
In the second example you have 2 equential SELECT CASE... the code does the same thing until when one of the conditions in the first SELECT CASE is activated AND the flow doesn't come back there after the calling.
to be clearer in the first SELECT CASE of the second example posted, if a condition matches (esc, riavvio, menu) then after activated the linked code the flow mustn't come back there in that SELECT CASE...
PS:
My answer is in english just to be accesible to all QB64 friends of this forum.