Xojo Code Folding

I was talking with another Xojo developer and we both commented on how neither of us use Code Folding in the Code Editor.  I’ve been using Xojo for fifteen years and this developer is at least ten years.


For-Next regular

If you’re not familiar with code folding it’s the ability to collapse an entire branch of an If – Then statement, Select – Case, For – Next, While – Wend, and probably a few others.  The code doesn’t go away, it’s just temporarily hidden.  It’s a convenient way to hide a good chunk of code so you can easily see what else is going on around it.

For Next Collapsed

For Next Collapsed

The other developer and I discussed this issue for a while and we really couldn’t come up with a good reason why.  The best reason we could come up with is that it *looks* like the code has been deleted.  Like I said, it wasn’t a good reason but at least it was a reason.

Do you use Code Folding? If not, why?

Have a Merry Christmas and Happy New Year folks!  Stay safe, enjoy time your family, and happy coding!

13 thoughts on “Xojo Code Folding

  1. I use code folding occasionally but not often. I have some long routines that are complicated, so when editing them it can be handy. It’s one of those features that is very useful from time-to-time and would be missed if it was removed.

  2. For me, I think it was because the feature was buggy and destroyed code when it was brand new. Something about collapsing a section, delete the wrong character, and the whole block got deleted.

    After that, I learned to never touch it again. If I do, I won’t edit code while collapsed.

  3. I use it occasionally when I have relatively long sections of code within conditional blocks to see an overview of the method logic.

    – Karen

  4. Use it all the time esp with long methods so I can collapse code down to focus on the bits I’m interested in
    We have a couple very long methods where this is immensely useful

    And, even if you NEVER fold the code up the markers are handy visual aids

    • True. I find the markers to be incredibly useful. For me it’s a visual guide to how complex the method is. If I have more than 2 ‘lines’ I feel like the method needs to be refactored to make it simpler.

  5. This feature exists in a lot of code editors, and I’ve always used it as a good indication of bad code smell. When code is so complex that I need to hide various control structures to reason about the code, it’s a good indication that the code should be refactored. I don’t know that I’ve ever used this feature in any code editor with much regularity, truth be told.

    • Same here. When the method becomes too long then it is time to refactor.

      Btw nice seeing you again, Aaron 😉

      • A long time ago, we kicked around the idea of a “code health indicator” as part of the method editor. It would start out with a “good” indicator (green badge, smiley face, something like that), and as a method got more complex, the indicator would change from good -> you should start worrying -> you should probably set the keyboard down and walk away.

        I still think that would be a good tool for many people to have, because complexity can be hard to spot. I think the biggest downsides to the idea were: measuring complexity can be expensive, and I can imagine scenarios where it would be nice to tune the complexity measurements to the individual. What I consider to be overly complex may be a reasonable amount of complexity to someone else.

        Good seeing you again, Markus, and happy new year! 🙂

  6. I’ve clicked it to open and close code, over and over, whilst trying to figure out a problem, but I’ve never used it as intended. I like seeing all my progress.

  7. When I head down code I always end up with some long methods that need refactoring. I use code folding to help keep organized in the process.

Comments are closed.