[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for code regions #285

Open
Sam-bit opened this issue Mar 22, 2019 · 9 comments
Open

Support for code regions #285

Sam-bit opened this issue Mar 22, 2019 · 9 comments

Comments

@Sam-bit
Copy link
Sam-bit commented Mar 22, 2019

Can we have code regions facility for dart just like #region in c# for structural code blocks purpose. And thus can be used in flutter also

@kevmoo kevmoo transferred this issue from dart-lang/sdk Mar 22, 2019
@munificent
Copy link
Member

My feeling has long been that #region is a somewhat useful feature in C#, but also implies there are other problems in the code. If a class is so big it needs to be broken down into "chapters", it's probably just too big.

For C#, the argument was that much of that code was generated WinForms code, so it made sense to be able to hide it. But I think partial classes (which if I recall came later) were a cleaner solution because it let you move that stuff to a separate physical file. That makes it much easier to integrate with code generators and otherwise manage things more cleanly.

For Dart, in many cases you can use mixins to break up a giant class into smaller more manageable pieces. You can even, if you want, put those all into the same file, which then also plays nice with library privacy.

I think that would be a better approach than applying a band-aid like #region.

@listepo
Copy link
listepo commented Mar 23, 2019

I think this is solved with a plugin for the IDE

@ercankayaNet
Copy link

which plugin?

@arbaieffendi
Copy link

This features would be useful

@ginuxone
Copy link
ginuxone commented Mar 4, 2020

while i agree with @munificent i think that in the other hand we have a spread of too much files and in some cases is useless to create another class in another file just to introduce one or two methods that can be more easily implemented on the file you already have.
In my case i have Auth and AuthProvider which basically are the same, they only differ that in Auth i have the 2 methods i use for new users registration. and in AuthProvider i have the login implementation.
In my personal case the use of regions could be a nice feature to have!

@techfan101
Copy link

Here's another vote for code regions as a useful feature.

While I agree with @munificent regarding classes that grow too large, I don't know that code regions actually encourage that growth. Sometimes bad developers are bad no matter how hard you wish they were better :)

Also, in some cases you may not have total control over the organization of your class. For example, you may be implementing a particularly large interface from an external package. In these cases, code regions can at least help organize the clutter from that (sometimes poorly designed) interface.

@anasnaguib
Copy link

This Feature will be very useful in managing parts for class, or parts of code written by different team members.

@mika76
Copy link
mika76 commented Mar 8, 2022

I would also love this, although I think it really only needs to be part of the vscode extension, not specifically the sdk?

which plugin?
https://marketplace.visualstudio.com/items?itemName=maptz.regionfolder

@munificent
Copy link
Member

Yeah, it's definitely possible for an IDE to support regions just by recognizing comments that contain some special marker text. In that case, no language support is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants