code folding

Inquie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 14 07:49:42 PDT 2017


Just for fun:

1. Folding directives are glorified comments. #region has zero 
meaning to the compiler; it's a hint to the editor to allow code 
folding. It doesn't do any namespacing or scoping. Why, exactly, 
are we writing code to accommodate the editor? It boggles my mind 
that we'd add significant lines of code to our project that do 
nothing but offer organizational hints to the editor. Even 
traditional comments are a better value for your keystroke, 
because they can be more expressive. And folding is certainly no 
substitute at all for bona-fide refactoring.

BS. I use regions in C# to separate disparate code. I like to 
know how my code functions and the structure of code relative to 
itself. It helps conceptually understand the code better.

2. Folding is used to sweep code under the rug. Got a bunch of 
boring boilerplate code that makes your eyes water? A slew of 
ugly, gnarly code that nobody in their right mind wants to look 
at? Hide it in a region and fold that sucker into oblivion! 
Problem solved, right? Hardly. Your project is now full of crappy 
code that you can't see. That's worse. Much worse! Code that 
hides from you is code that will rot in the most putrescent and 
painful way possible. Your code should be front and center at all 
times -- exposed to as many programmers' eyes, and as much 
healing light, as possible.

No matter what color language you use to object to something 
doesn't mean it is more true. I guess this guy doesn't realize 
that you can unfold the code.

3. Folding is used to mask excessive length. The presence of 
folded code can lull developers into a false sense of what clean 
code looks like. Under the cover of folding, you can end up 
writing long, horrible spaghetti code blocks. If the code needs 
the crutch of folding to look organized, it's bad code.

Well duh, that is one of the benefits of it.

I'll state it again. I use regions in C# to separate disparate 
code. I like to know how my code functions and the structure of 
code relative to itself. It helps conceptually understand the 
code better.



4. Folding can hide deficiencies in your editor. The presence of 
so-called "standard" boilerplate regions like "Public 
Constructors" and "Public Properties" and "Events" is not a 
feature. It's a bug. The editor should automatically offer to 
fold up these common structural blocks for you! I'm continually 
amazed that programmers spend time doing this scutwork when they 
could be writing useful code. Or at least demanding a smarter 
code editor.

This guy obviously doesn't know what a bug is so how could we 
trust his "expertise"? But which is it? the language or the 
stupid IDE? I'm confused?


This guy probably never used #regions to learn how to use them 
properly and has such a pathetic uptight life that all he can do 
is bitch about other peoples poor code practices. That is no 
proof of anything. Instead of bitching, like most people, why 
didn't he write a constructive article about how to use #regions 
properly?

Anyone can write a blog these days.... kinda sad actually. ;/



I guess you will then state that he is an amazing programmer 
because of SO and that we should all bow down to his wisdom? 
yeah, right....




More information about the Digitalmars-d-learn mailing list