Android Tutorial [Wish] Code folding

rfresh

Well-Known Member
Licensed User
Longtime User
Thanks...That's a help but I wish it was automatic for all of them like it is for subs.
 

Troberg

Well-Known Member
Licensed User
Longtime User
Regions are neat, but not for everything. Typical example:

B4X:
If OperationWorked Then 'Process result
  'Do lots of stuff
Else 'Error handling
  'Do some error handling
End If

In a case like that, I like to hide the error handling when it's done. It's an exception that's not part of the normal program flow, and I don't need to see it when I do the tougher parts in the normal execution path. Also, it's not uncommon to nest several levels of tests like these, all of them having a "tail" that is not used unless something is wrong (say, when testing a bunch of arguments to see if they are valid). It's just trivial code that needs to be there, but I don't want to see it as it obfuscates what I'm realling doing.

Having a bunch or regions here would add a lot do "code space overhead", and hardly contribute to the visibility. Having the above code fold to:

B4X:
If OperationWorked Then 'Process result
   'Do lots of stuff
Else 'Error handling
End If

would be much better, and once the code is done, folding it to:

B4X:
If OperationWorked Then 'Process result
Else 'Error handling
End If

would give a very clean, readable view of what the code does from a "cloud free altitude".
 
Top