A lot of times you’d think that single lines of code, aka “one-liners”, like
if j >= 145 condition then dosomething()
or
if condition then return
might not have any downsides. I would argue that they do.
You can’t put a break point on the code that runs when the condition is true. And though sometimes this may not matter, when it does, like when you want to step into the method or code that is run, you have to turn the one-liner into a multi-line If…End If statement.*
if j >= 145 condition then dosomething() end if
or
if condition then return end if
This allows you to put the break point on the code and not on the conditional. If it is code that gets run a lot, this can be a big deal.
This is why, as I go through the Xojo IDE code base, I usually remove one-liners and turn them into multi-line if … end if statements. This way I can break on the code and not the conditional, and in some cases this saves many hundreds of calls and having to step through the code.
As always, remember that what you do today can save your sanity or break it tomorrow! 🙂
* Yes if you want to debug the called method every time you can put the break point in the called method. If you want to only break in this specific case, you have to rewrite the if statement so you can put a break on the method call line.