Friday, April 3, 2015

#regions inside methods.

You know what I really, really hate.

#region declarations INSIDE of methods.

#regions OUTSIDE of methods is completely fine, makes code better organized (when used correctly), and overall helps us find things better.

But INSIDE METHODS?

I just saw one inside of a method, the region was called:

load the data

And it had about 5 lines of code. FIVE!

How does this help organization? Now I have to go click the + sign in VS just to see your 5 lines of code.

Now imagine this EVERYWHERE in a project, and you have an idea of what I am going through right now.

Hey, if you like regions inside methods, you know what you should REALLY be using?

SUBMETHODS.

Submethod the shit out of every embedded #region you have. Too many submethods? Make a new class. Reuse code. Keep it consistent. Keep it meaningful. Make it look like you actually give a fuck about what your code looks like. Don't worry, you have enough time. Hell, you'll probably save some.