-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (83 loc) · 6.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="anti-region-legion.org : Because it's time to #endregions">
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>anti-region-legion.org</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/Anti-region-Legion">View on GitHub</a>
<h1 id="project_title">anti-region-legion.org</h1>
<h2 id="project_tagline">Because it's time to #endregions</h2>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h1>
<a name="the-anti-region-legion" class="anchor" href="#the-anti-region-legion"><span class="octicon octicon-link"></span></a>The Anti-<code>#region</code> Legion</h1>
<p>The Anti-<code>#region</code> Legion is a community for people that believe that the <code>C#</code> <a href="http://msdn.microsoft.com/en-us/library/9a1ybwek%28v=vs.110%29.aspx"><code>#region</code></a> is a unfortunate part of the language. </p>
<p>If you just love your regions The Anti-<code>#region</code> Legion is probably not for you. But it is suggested that you read <a href="http://www.richard-banks.org/2011/02/anti-region-campaign.html">Richard Banks post on some of the issues with regions</a>. </p>
<h2>
<a name="how-do-i-join-the-legion" class="anchor" href="#how-do-i-join-the-legion"><span class="octicon octicon-link"></span></a>How do I join the Legion?</h2>
<p>You can <a href="https://github.com/Anti-region-Legion/Anti-region-Legion.github.io">join by starring this repository</a> (if you have a github account), or join in the conversation on social media such as Twitter using hashtag <code>#endregions</code>. You are also encouraged to <a href="https://github.com/Anti-region-Legion/Anti-region-Legion.github.io/issues">suggest your own ideas to this site on the <em>issues</em> page</a>.</p>
<h2>
<a name="what-does-an-upstanding-member-of-the-legion-do" class="anchor" href="#what-does-an-upstanding-member-of-the-legion-do"><span class="octicon octicon-link"></span></a>What does an upstanding member of the Legion do?</h2>
<p>Join us in practicing and preaching good code practices, such as using the following ways to deal with grouping and organization of expanding code (rather than regions):</p>
<ol>
<li>
<em>Partial class</em> - a useful methodology of moving dependency items (such as properties or methods) without refactoring a code-base with a rippling change</li>
<li>
<em>Extract methods</em> - improve the JIT's ability to optimize performance by allowing it to not load sections of code if the branch hasn't been or can never be exercised by extracting methods out of the contents of large block statements (if/else,for/while,anonymous delegates,etc)</li>
<li>
<em>Single responsibility</em> - reduce complexity of classes by encapsulating the responsibility for aspects of functionality to designated layers and objects</li>
</ol><h2>
<a name="i-just-want-to-get-rid-of-all-regions-in-my-code-now" class="anchor" href="#i-just-want-to-get-rid-of-all-regions-in-my-code-now"><span class="octicon octicon-link"></span></a>I Just Want to Get Rid of All Regions in My Code Now!</h2>
<p>Ok, here are a couple of quite simple ways to do that. One command line and one from within Visual Studio.</p>
<p><em>Command line</em> - run this PowerShell command in your toplevel source folder(s) (c# class files only):</p>
<pre><code>dir -recurse -filter *.cs $src | foreach ($_) {
$file = $_.fullname
echo $file
(get-content $file) | where {$_ -notmatch "^.*\#(end)?region.*$" } | out-file $file
}
</code></pre>
<p>You can read more on <a href="http://richarddingwall.name/2010/08/12/powershell-to-recursively-strip-c-regions-from-files/">Richard Dingwall's blog</a>. </p>
<p><em>Visual Studio</em>:
Press <code>ctrl</code> + <code>shift</code> + <code>H</code> to "Replace in Files" and as "Find options" "Use Regular Expressions". Then search for <code>^[ \t]*\#(region|endregion).*\n</code> and replace it with nothing/empty string. </p>
<p>See <a href="http://stackoverflow.com/a/13382749/587279">more details in this stackoverflow answer</a>.</p>
<h2>
<a name="my-team-wont-let-me-delete-the-regions" class="anchor" href="#my-team-wont-let-me-delete-the-regions"><span class="octicon octicon-link"></span></a>My Team Won't let me Delete the Regions!?</h2>
<p>Poor you. If you just want to see the code within collapsed regions you can use <code>ctrl</code> + <code>M</code>, <code>ctrl</code> + <code>L</code> to toggles between expand and collapse all sections. </p>
<p>There is even a <a href="http://visualstudiogallery.msdn.microsoft.com/0ca60d35-1e02-43b7-bf59-ac7deb9afbca">Visual Studio extension that does this and more automatically</a>. </p>
<h2>
<a name="history" class="anchor" href="#history"><span class="octicon octicon-link"></span></a>History</h2>
<p>The idea for the anti-<code>#region</code> legion started from a <a href="https://twitter.com/jrusbatch/status/392473615557746688">twitter conversation</a> which again was started from <a href="https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2678342-region-directive-considered-harmful-was-get-rid">Microsoft declining to remove <code>#region</code>s from c#</a>. </p>
<h2>
<a name="how-can-i-show-my-anti-region-legion-membership" class="anchor" href="#how-can-i-show-my-anti-region-legion-membership"><span class="octicon octicon-link"></span></a>How can I show my anti-<code>#region</code> legion membership?</h2>
<p>Be creative! Make a sticker, tag your computer with <code>#endregions</code> or buy a <a href="http://www.cafepress.com/cp/customize/product2.aspx?number=1005536199">t-shirt</a>. </p>
<p><strong>Join the anti-<code>#region</code> Legion today!</strong></p>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-46042487-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>