Be able to set a region in a defined piece of code

Most code structure nazis cringe at the thought of this, I'm sure

For good reason. It's much harder to add/delete lines of code when the one-command-per-line rule is violated.

It is possible to create additional files in a sketch directory, and move tested/utility/related functions out of the main sketch, to reduce the size of the sketch. This is the approach that libraries take.

I have resorted to placing multiple commands on a single line in order to shorten the overall length of the sketch. Most code structure nazis cringe at the thought of this, I'm sure, but it has become a necessary evil to me.

I usually pay attention not only to code structure, but even to the number of blanks between a closing paren and an opening brace.
I even align comments.
Trashing code structure just to "shorten the length of the sketch" is a very, I mean VERY bad idea. You're trading a fundamental code maintenance requirement for the nuisance of scrolling through a long text file. The "necessary evil" you're talking about is learning how to split a sketch into multiple files or, better yet, learn how to write libraries (this site has a very good tutorial).

:slight_smile:

The Arduino way is "for the rest of us"...
Compared to any (semi-)professional programming editor the Arduino IDE is a good joke.

However its simplicity suits the newcomer.

I think a lot can be done by using the tab-feature of the IDE. To my astonishment hardly anyone ever wondered what that small arrow at the right hand side of the IDE window could be :slight_smile:

Using such "modules" can structure your code quite efficiently without the need for libraries....

Separate files/classes/libraries etc. etc. doesn't always make for more readable code.

I don't think the IDE is a "joke", but can't see any harm in implementing a simple user-defined collapsable region as used in things like Visual Studio.

#region Input Code

  • code goes here
    #endregion

Then if you don't like it, you don't have to use it.

But I am not against your proposal!

Good design, however, is a matter oh hierarchical decomposition (or "abstracton"). Though two levels are by far not enough for larger projects, they will help a lot. Of course the tab feature can be used for any number of levels, but you will not "see" the level, so the main use will be to separate the main module and one level of submodules, which should carry 80% of the code burden....

Puttiing everything in one file - folded or unfolded - is as awkward as putting every class into a separate file :slight_smile:

But I am not against your proposal!

Oh I know, and I wasn't trying to counter you specifically as you made perfectly valid points and suggestions.

In some cases, too many levels of code separation is counter-productive and a simple collapsable region would be an additional facility for those of us who like to use them. Ideally, only when it is still sensible to do so. :slight_smile: