|
Blog -
Coding
|
|
Written by Jmaxxz
|
|
Sunday, 06 December 2009 13:59 |
|
I am sure we have all worked with someone at one point or another who takes their job way too seriously. You've just written up the most awesomest code ever, but you need to get it through a code review. Unfortunately the guy who does code reviews likes object oriented programing (what a sell out). You know if you hand it to him your code as it is now he will just tell you to rewrite it all and use more classes, more methods, comments on your methods, and better code structure. So how do you get him to give you the thumbs up to check in your code?
Well fortunately for you Microsoft has built a feature into c# which will let you take all that beautiful complexity and leetness and hide it. After you are done your files will appear to be only a matter of lines long. Just do:
#region Some OO sounding name, implying a 'good design' like FooObserver
//put some decoy code here something to make your code look structured
#region local variable declaration
//all your 1337 C0|)3
if(8==9-1)
{
return bar;
}
#end region
//more decoy code here, a return statement is good, notice it is not reachable
return foo;
#endregion
With any luck when you hand this off to your reviewer he will look at your regions, and think your class is very concise, and well structured, and just so long as he does not dig too deep he will let you check it in.
Seriously, regions are evil, their sole purpose is to make ugly code look pretty. Never use them, and if you are the reviewer be smart, and if code has regions return to sender.
|
|
Last Updated on Sunday, 06 December 2009 14:26 |