Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Declare Active Conventions inside C# or VB.NET Source Code
travislaborde
follow
0
6-26-2008 7:43 AM
560 views
tags:
programming
,
.net
travislaborde
says:
NDepend is awesome
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
The Future Of Code, Digital And Genetic Co...
Favorite Programming Quotes
The Great Depression Hoax
MSNBC's Network Chief Down Plays The Pers...
Free Online Courses from Great Universities
OH voting machines contain critical vote-d...
Cheezburger LOLz for ALLz
More clips from
travislaborde
How "The Price is Right" SHOULD Work :)
Pictures - Taken Just At The Right Time
THE BEST MAN TURNED OUT TO BE A WOMAN
Today's Top Clips
List of books Palin wanted banned--wow!
Why is pleasure so suspicious?
The investigation of laughter is belatedly becoming a science..:-)
Palin's foreign experience - not very impressive
The Psychology of Conservatism
A satellite eye on the Earth
True Graffiti
Toying with our perception of time..
Design - Rotator bath/shower by Arad for Teuco
Photos Taken At Just The Right The Moment!
visit the
Top Clips page
View the Top Clips from
June 26, 2008
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://www.clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/4c718905-f869-4b7d-a486-6165eba37964/AD60D22A-D2AB-4DF2-A70C-2FA7AA1DB88C/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx" href="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx" style="font-size: 11px;">codebetter.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><H4 class="BlogPostHeader">Declare Active Conventions inside C# or VB.NET Source Code </H4></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><P>With the last version of <A target="_blank" href="http://www.NDepend.com">NDepend</A>, we polished one particular scenario that I would like to describe properly: The possibility to store <A target="_blank" href="http://www.ndepend.com/Features.aspx#CQL">CQL</A> rules inside source code.<BR /></P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx">Consider this piece of code:</blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><div align="center"><img src="http://content6.clipmarks.com/blog_cache/codebetter.com/img/FB166EC3-716D-49F8-BBA6-25A6960A2720" alt="" /></div></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx">let's write a custom convention that checks that:</blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"> When a method is calling the method <I>Foo1()</I>, it <B>must </B>also call the method <I>Foo2(int)</I>.</blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><div align="center"><img src="http://content7.clipmarks.com/blog_cache/codebetter.com/img/3B492E1E-B9B8-4088-9D11-3847359BF734" alt="" /></div></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx">Right click the editor and select: <I>Copy to clipboard to insert this query in C# source code</I> ...</blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><div align="center"><img src="http://content8.clipmarks.com/blog_cache/codebetter.com/img/1B27049B-44AB-4B20-8097-C5A242B0DDF4" alt="" /></div></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx">... and paste the clipboard content just before the <I>Fct1()</I> method definition. An attribute is now tagging the <I>Fct1() </I>method definition.</blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx"><div align="center"><img src="http://content9.clipmarks.com/blog_cache/codebetter.com/img/9900789D-2CB3-4808-BFBE-459284007557" alt="" /></div></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://codebetter.com/blogs/patricksmacchia/archive/2008/06/25/declare-active-conventions-inside-c-or-vb-net-source-code.aspx">It makes sense to declare such constraint near the <I>Foo1() / Foo2(int)</I> methods definitions. This way, during code review or refactoring developers cannot miss it. This is active documentation. </blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/AD60D22A-D2AB-4DF2-A70C-2FA7AA1DB88C/blog/" title="blog or email this clip"><img src="http://content6.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK