Idea for Numbering your large if statements
Posted: 15 Feb 2010
Not a contributed study but rather something to consider to help with coding your studies and maintaining them. Specifically to get back to any section of the if statement very fast.
Each if statement (that is large or that I think might become very large) has a code number I just randomly grab out of my head. I potentially apply the number to 5 places in the if statement. As you can see below there is a sub code structure too (B1, E1, B2, E2). I apply these where it seems appropriate. I included all four subcodes in the example below just to make it clear as to why I chose these subcode numbers.
It should be very clear now why I used (B1, E1, B2, E2) for the subcodes.
B1 is Begin1.
E1 is End1.
B2 is Begin2.
E2 is End2.
This allows you to jump to any section of the if statement fast.
Duplicating the actual if statement within the comment code as I did above is useful when you have a large if statement that is way off your screen. If you change the actual if statement such as from > to >= then the numbering system lets you update the comments faster to match this change.
If you want to quickly jump through the large if statements you have assigned a code to, then search on "IF:".
IF you want to jump around just this one if statement use "IF:745"
It is easy to memorize the if numbers or just quckly jot the number down on some scrap paper at your desk to get back to any section of the if statement fast. You could even list the codes at the top of your study with the comment for each if statement. Next time you work on the study just cut/paste the top section out to a scrap word document and within 30 seconds you are moving around your study you completed 3 months ago just as fast as if you wrote it yesterday.
As an after thought, I am working on two studies that have similar if statements (one is 1 minute bars and the other is 10 second bars). I am using the same if code number for the statement that has exactly the same function in both studies.
I find structuring my if statements with the code indent method above keeps the code cleaner as well as lending itself to this search technique.
Each if statement (that is large or that I think might become very large) has a code number I just randomly grab out of my head. I potentially apply the number to 5 places in the if statement. As you can see below there is a sub code structure too (B1, E1, B2, E2). I apply these where it seems appropriate. I included all four subcodes in the example below just to make it clear as to why I chose these subcode numbers.
Code: Select all
if bartype = 1 and barinterval = 1 then {IF:745 - purpose comments}
begin {IF:745B1}
{large amounts of code in here with deep nested if statements}
end {IF:745E1 - if bartype = 1 and barinterval = 1 then}
else
begin {IF:745B2 - if bartype = 1 and barinterval = 1 then}
{large amounts of code in here with deep nested if statements}
end; {IF:745E2 - if bartype = 1 and barinterval = 1 then}
B1 is Begin1.
E1 is End1.
B2 is Begin2.
E2 is End2.
This allows you to jump to any section of the if statement fast.
Duplicating the actual if statement within the comment code as I did above is useful when you have a large if statement that is way off your screen. If you change the actual if statement such as from > to >= then the numbering system lets you update the comments faster to match this change.
If you want to quickly jump through the large if statements you have assigned a code to, then search on "IF:".
IF you want to jump around just this one if statement use "IF:745"
It is easy to memorize the if numbers or just quckly jot the number down on some scrap paper at your desk to get back to any section of the if statement fast. You could even list the codes at the top of your study with the comment for each if statement. Next time you work on the study just cut/paste the top section out to a scrap word document and within 30 seconds you are moving around your study you completed 3 months ago just as fast as if you wrote it yesterday.
As an after thought, I am working on two studies that have similar if statements (one is 1 minute bars and the other is 10 second bars). I am using the same if code number for the statement that has exactly the same function in both studies.
I find structuring my if statements with the code indent method above keeps the code cleaner as well as lending itself to this search technique.