<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Dev Bros &#187; .net</title>
	<atom:link href="http://www.webdevbros.net/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevbros.net</link>
	<description>hot talk about web development</description>
	<lastBuildDate>Wed, 16 Dec 2009 12:59:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Role Based Access Control in ASP.Net MVC</title>
		<link>http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/</link>
		<comments>http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 12:59:24 +0000</pubDate>
		<dc:creator>Dai Bok</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[general stuff]]></category>
		<category><![CDATA[Access Control]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Bitwise Operations]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/?p=874</guid>
		<description><![CDATA[Currently I am looking at access control systems, and how best to integrate them with ASP.Net MVC framework. While this framework already provides support for role based access control (RBAC), using the membership classes. I need to implement this on a legacy database, and some how integrate the old system with asp.net forms authentication. This [...]]]></description>
			<content:encoded><![CDATA[<p>Currently I am looking at access control systems, and how best to integrate them with ASP.Net MVC framework. While this framework already provides support for role based access control (RBAC), <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membership.aspx">using the membership classes</a>. I need to implement this on a legacy database, and some how integrate the old system with asp.net forms authentication. This post is about how I realised this, and acts a potential solution. If you can think of a better way, of find any devastating flaws, let me know. ;-)</p>
<p>The scenario is simple, we have four roles defined for the system. They are Students, Graduates, Staff and Administrators. Some staff can be graduates, (or even Students). Administrators are, of course staff! So how you model this? We already know of one bitwise <a href="http://www.webdevbros.net/2006/12/02/toggle-states-like-active-deleted-etc-bitwise-negation-in-sql/">trick from Michal’s post</a>, so let us see how we can use bitwise operations to make this a reality!</p>
<p>First let us revise the results of the bitwise AND operations. You can check<a href="http://en.wikipedia.org/wiki/Bitwise_operation"> Wikipedia for full details</a>.</p>
<p align="center">
<table style="border:1px solid black" cellspacing="0">
<tr>
<td>1
<td>&amp;
<td>0
<td>=
<td>0 </tr>
<tr>
<td>0
<td>&amp;
<td>1
<td>=
<td>0 </tr>
<tr>
<td>0
<td>&amp;
<td>0
<td>=
<td>0 </tr>
<tr>
<td>1
<td>&amp;
<td>1
<td>=
<td>1 </tr>
</table>
<p>
</p>
<p>Converting these back to decimal 1001 is 9 and 0101 is 5. So 9 &amp; 5 = 8. If we convert each of these bits to represent a role in our system, we can come up with a table like this. </p>
<p align="center">
<table style="border:1px solid black" cellspacing="0">
<tr>
<td>Bit 1
<td>0 (false)
<td>Student</tr>
<tr>
<td>Bit 2
<td>0 (false)
<td>Graduate</tr>
<tr>
<td>Bit 3
<td>0 (false)
<td>Staff</tr>
<tr>
<td>Bit 4
<td>1 (true)
<td>Admin</tr>
</table>
<p>
</p>
<p>So a user of the system with a role number of 8 is an Admin, but in our case, an Admin is also a member of staff, and in fact, a member of staff could also be a student or a graduate. This is where using bitwise operations can really help model such a situation.  To get it working, a staff member who is a student will have bits 1 and 3 set to true, while a graduate who is also a staff member will have bits 2 and 3 set to true. We can represent these roles in decimal as User(Staff &amp; Graduate) = 6, while User (Staff &amp; Student) = 5. Get the picture?</p>
<p>Let’s look at a simple real world example. First we have a User class, with a Role property of the type int. The reason we use an integer, is that is can be easily stored in the database.</p>
<div style="font-family: Courier New;font-size: 10pt;color: black;background: white">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">User</span> {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">string</span> Name { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">int</span> Role { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">bool</span> IsInRole(<span style="color: #2b91af">Role</span> role) {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">//todo</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>
</div>
<p>We also need to create an enumeration, with a Flags attribute. The flags attribute tells the compiler that this enumeration can be treated as a bit field. We then define a value for each role. The reason for using exponents of 2 should become clearer later. </p>
<div style="font-family: Courier New;font-size: 10pt;color: black;background: white">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;&nbsp;&nbsp;&nbsp; [<span style="color: #2b91af">Flags</span>]</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">enum</span> <span style="color: #2b91af">Role</span> {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Student = 1,&nbsp;&nbsp;&nbsp; <span style="color: green">// 0001</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Employer = 2,&nbsp;&nbsp; <span style="color: green">// 0010</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Staff = 4,&nbsp;&nbsp;&nbsp; &nbsp; <span style="color: green">// 0100</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Admin = 8&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <span style="color: green">// 1000</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>
</div>
<p>The menu of our website needs to be generated depending on the user role.  The menu selection code below should generate the correct menu depending on the user role.</p>
<div style="font-family: Courier New;font-size: 10pt;color: black;background: white">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;</span><span style="color: #a31515">div</span> <span style="color: red">class</span><span style="color: blue">=&quot;LeftMenu&quot;&gt;</span>&nbsp; </p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> <span style="color: blue">if</span> (user.IsInRole(<span style="color: #2b91af">Role</span>.Student)) <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> Html.RenderPartial(<span style="color: #a31515">&quot;StudentMenu&quot;</span>); <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> <span style="color: blue">if</span> (user.IsInRole(<span style="color: #2b91af">Role</span>.Graduate)) <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> Html.RenderPartial(<span style="color: #a31515">&quot;GraduateMenu&quot;</span>); <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> <span style="color: blue">if</span> (user.IsInRole(<span style="color: #2b91af">Role</span>.Staff)) <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;10</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> Html.RenderPartial(<span style="color: #a31515">&quot;StaffMenu&quot;</span>); <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;11</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;12</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> <span style="color: blue">if</span> (user.IsInRole(<span style="color: #2b91af">Role</span>.Admin)) <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;13</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="background: #ffee62">&lt;%</span> Html.RenderPartial(<span style="color: #a31515">&quot;AdminMenu&quot;</span>); <span style="background: #ffee62">%&gt;</span></p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;14</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;15</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;</span></p>
<p>
</div>
<p>Ok, so let see where the magic happens!  If we <a href="http://msdn.microsoft.com/en-us/library/sbf85k1c.aspx">AND (&amp;)</a> the user assigned role, with the role required, and we compare this result to the role required, we can determine if a user is in the role.  Summarised, the end result of the AND operation needs to equal that of the role required. In user class we have the method:</p>
<div style="font-family: Courier New;font-size: 10pt;color: black;background: white">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">bool</span> IsInRole(<span style="color: #2b91af">Role</span> role) {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af">Role</span> userRole = (<span style="color: #2b91af">Role</span>)<span style="color: blue">this</span>.Role;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> ((userRole &amp; role) == role);</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p>
</div>
<p>Looking at some binary examples, we can see how it works. In the first example, an admin user wants accesses a graduate item. </p>
<p align="center">
<table style="border:1px solid black" cellspacing="0">
<tr>
<td>Role Required
<td style="color:red">Staff(4)
<td>0 1 0 0</tr>
<tr>
<td>User Role
<td style="color:green">Admin (8)
<td>1 0 0 0</tr>
<tr>
<td>Result of &amp;
<td style="color:red"> Access Denied (0)
<td>0 0 0 0</tr>
</table>
<p></br>
</p>
<p>It is clear that we have a problem here, because we said that admin could be both staff, and staff may also be graduates.  What we need to do is add up the roles, so that this user will access both admin and staff content. Assigning the user the role of Admin and Staff is easy. All we do is: </p>
<div style="font-family: Courier New;font-size: 10pt;color: black;background: white">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af">User</span> user = <span style="color: blue">new</span> <span style="color: #2b91af">User</span>();</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.Role = (<span style="color: blue">int</span>)<span style="color: #2b91af">Role</span>.Staff;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.Role += (<span style="color: blue">int</span>) <span style="color: #2b91af">Role</span>.Admin;</p>
<p>
</div>
<p>And the resulting table is: </p>
<table style="border:1px solid black" cellspacing="0">
<tr>
<td>Role Required
<td style="color:red">Staff(4)
<td>0 1 0 0</tr>
<tr>
<td>User Role
<td style="color:green">Admin  + Staff (12)
<td>1 1 0 0</tr>
<tr>
<td>Result of &amp;
<td style="color:green">Access Granted (4)
<td>0 1 0 0</tr>
</table>
<p>
</p>
<p>Now we can easily draw our menu depending on the roles assigned to a user. Adding or removing roles for a user is also easy, just add it or subtract it. I wrote a little project to go with this so you can test it our your self.  Thanks to Michi for introducing  this, and Dan for helping work it out! </p>
<p>Download the <a href='http://www.webdevbros.net/wp-content/uploads/2009/12/Roles.zip'>Roles sample project </a>  You’ll need to use <a href="http://www.nunit.org/">nUnit to test it</a>. </p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/&amp;t=Role+Based+Access+Control+in+ASP.Net+MVC&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/&amp;title=Role+Based+Access+Control+in+ASP.Net+MVC&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/&amp;title=Role+Based+Access+Control+in+ASP.Net+MVC&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Role+Based+Access+Control+in+ASP.Net+MVC;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2009/12/16/role-based-access-control-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>picnik comes with a free-to-use image editing API for your website</title>
		<link>http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/</link>
		<comments>http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 03:32:11 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/</guid>
		<description><![CDATA[ Ever heard from Picnik? It allows you editing your images direclty within your browser. Forget Adobe Photoshop :) Picnik has been around for a while now but recently it started to offer its service for the public. for free! I played around a bit and must say that it is amazing .. Use it [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webdevbros.net/wp-content/uploads/2008/01/picnic.gif' alt='picnic.gif' style="float:left"/> Ever heard from <a href="http://www.picnik.com">Picnik</a>? It allows you editing your images direclty within your browser. Forget Adobe Photoshop :) Picnik has been around for a while now but recently it started to offer its service for the public. for free! I played around a bit and must say that it is amazing .. Use it within PHP, classic ASP, .net, Ruby on Rails  or whatever... especially i like the idea of the whole service which works like this...</p>
<ol>
<li>Send your images to their service (existing image via URL or encoded as multi-part)</li>
<li>Then the user modifies the picture (size, colors, rotation, special effects...)</li>
<li>Picnik sends you the picture back to your server (either an URL where you can download it or directly as multi-part image)</li>
</ol>
<p>Here comes an example I have built for demonstration...<span id="more-149"></span>Click on the picture below to edit it.</p>
<p><a href="http://www.picnik.com/service/?_apikey=178ef7667a0c301dd8eb89e76caba626&#038;_import=http%3A//www.webdevbros.net/wp-content/uploads/2008/01/googleapple.jpg&#038;_export=http%3A//www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website&#038;_export_title=back%20to%20webdevbros"><img src='http://www.webdevbros.net/wp-content/uploads/2008/01/googleapple.jpg' alt='googleapple.jpg' /></a></p>
<p>Everything realized by using a link to this URL:</p>
<div class="igBar"><span id="lhtml-2"><a href="#" onclick="javascript:showCodeTxt('html-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-2">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">http://www.picnik.com/service/</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; ?_apikey=178ef7667a0c301dd8eb89e76caba626</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ddbb00;">&amp;_import=http%3A//www.webdevbros.net/wp-content/uploads/2008/01/googleapple.jpg</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &amp;_export=http%3A//www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &amp;_export_title=back%20to%20webdevbros </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pretty cool isn't it? Thats the basic example but you can customize a lot more (see their <a href="http://www.picnik.com/info/api/reference">API</a>). Also I didn't progress the picture back on my server.</p>
<p>If you want to get started i recommend to start with their <a href="http://www.picnik.com/info/api/tutorials">tutorials</a>. They are nicely written and done in 10 minutes.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/&amp;t=picnik+comes+with+a+free-to-use+image+editing+API+for+your+website&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/&amp;title=picnik+comes+with+a+free-to-use+image+editing+API+for+your+website&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/&amp;title=picnik+comes+with+a+free-to-use+image+editing+API+for+your+website&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=picnik+comes+with+a+free-to-use+image+editing+API+for+your+website;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2008/01/23/picnik-comes-with-a-free-to-use-image-editing-api-for-your-website/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# tips, tricks and things you should know</title>
		<link>http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/</link>
		<comments>http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 11:33:25 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming style]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/</guid>
		<description><![CDATA[ During my previous holidays (i have to admit 1.5 months surfing in portugal) I had some literature with me which also included the book Programming .net components released with O'Reilly. It talks about the aspects of components in general and provides good examples how to achieve those in .net. Although these pages are a [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webdevbros.net/wp-content/uploads/2007/11/dotnetcomponents.jpg' alt='.net components' align='left' /> During my previous holidays (i have to admit 1.5 months surfing in portugal) I had some literature with me which also included the book <a href="http://www.amazon.com/Programming-NET-Components-Juval-Lowy/dp/0596102070/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1195026384&#038;sr=8-1">Programming .net components</a> released with O'Reilly. It talks about the aspects of components in general and provides good examples how to achieve those in .net. Although these pages are a very good read (rather for experienced devs) for ppl interested in component development, I found it more interesting because of its general C# content. There are concepts &#038; approaches, small tips &#038; tricks and intersting things about C# which can be used not only in component based architectures and are therefore good to know anyway. </p>
<p>As I always make notes while reading "geek" books I thought: "so why not summarize them all up in a nice list and blog'em". Here we go...<span id="more-115"></span></p>
<p><strong>1. implicit vs explicit interface</strong><br />
implicit interface implementation allows to use the interface member through an object or through the interface whereas the explicit interface implementation allows only access through the interface.</p>
<div class="igBar"><span id="lcsharp-15"><a href="#" onclick="javascript:showCodeTxt('csharp-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-15">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//public interface IInterface {</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">void</span> Foo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//implicit implementation</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> AClass : IInterface <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Foo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//explicit implementation</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> BClass : IInterface <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">void</span> IInterface.<span style="color: #0000FF;">Foo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//usage implicit</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AClass a = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> AClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">a.<span style="color: #0000FF;">Foo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">IInterface b = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> AClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">b.<span style="color: #0000FF;">Foo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//usage explicit</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">IInterface c = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> BClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">c.<span style="color: #0000FF;">Foo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BClass d = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> BClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">d.<span style="color: #0000FF;">Foo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">//Fails because of explicit implementation!!! </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Visual studio just offers the choice of the implementation but most people don't know the difference. With explicit implementation the server (implementing the interface) can prevent clients from using it directly on object which implements it. It forces that the members of the interfaces are only accessible via the interface itself</p>
<p><strong>2. implicit vs explicit cast</strong><br />
this is just to get used to the terminology because a lot of guys are using it but don't know the terminology ;)</p>
<div class="igBar"><span id="lcsharp-16"><a href="#" onclick="javascript:showCodeTxt('csharp-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-16">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//implicit cast</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">T x = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> T</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//explicit cast</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">T x = <span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span>y</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//explicit cast (defensive)</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">T x = y <span style="color: #0600FF;">as</span> T </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here you see that implicit casting is assigning a class instance directly to a variable. Explicit means casting from one type to another. </p>
<p><strong>3. Destructors</strong><br />
A destructor of a class is defined with ~ClassName. In comparison to Dispose() the C# destructor is always called. Dispose() needs to be called by the client whereas the destructor is called when the garbage collector comes around. Best way is to implement both and channel the implementation to the method which does the cleanup. e.g. cleanup. Example of implementation [COMP05, 98]:</p>
<div class="igBar"><span id="lcsharp-17"><a href="#" onclick="javascript:showCodeTxt('csharp-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-17">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MyBase : IDisposable <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">private</span> <span style="color: #FF0000;">bool</span> _disposed = <span style="color: #0600FF;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">protected</span> <span style="color: #FF0000;">bool</span> Disposed <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; get <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">lock</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> _disposed;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Dispose<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">lock</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>!_disposed<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CleanUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _disposed = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GC.<span style="color: #0000FF;">SuppressFinalize</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//the method for the subclasses if they need to release resources</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> CleanUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;~MyBase<span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; CleanUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Classes deriving from this baseclass can now implement their destruction by overriding the cleanup method and can now decide to do the clean up manually (calling Dispose) or leave it till the GC comes around. Important here is that if Dispose() was called we tell the garbage collector to exclude this instance from being garbaged later (with GC.SuppressFinalize()).</p>
<p><strong>4. use "Using" defensive</strong></p>
<div class="igBar"><span id="lcsharp-18"><a href="#" onclick="javascript:showCodeTxt('csharp-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-18">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>obj <span style="color: #0600FF;">as</span> IDisposable<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This approach will only call Dispose() if the object implements IDisposeable. Good if you dont really know if the object needs to release resources or not and if you want to be ready for future changes. e.g. the server decides to implement IDisposeable.</p>
<p><strong>5. Delegate inference</strong></p>
<div class="igBar"><span id="lcsharp-19"><a href="#" onclick="javascript:showCodeTxt('csharp-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-19">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//instead</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">publisher.<span style="color: #0000FF;">someDelegate</span> += <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">Delegate</span><span style="color: #000000;">&#40;</span>someMethod<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//u can use</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">publisher.<span style="color: #0000FF;">someDelegate</span> += someMethod </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is much nicer to read but only supported with .net 2.0.</p>
<p><strong>6. Custom event arguments</strong><br />
Custom event arguments (own class derrived from EventArgs) should have only readonly members. This prevents the client from changing the values. Readonly members can only be assigned in the constructor so the publisher of the event is able to set the values when creating the arguments.</p>
<p><strong>7. Always fire events in a try catch block</strong><br />
You never know what the event handler method of the client does, so its good to put the firing into a try catch block. You could write your own EventsHelper class [COMP05, 144] for the purpose of firing event within your classes.</p>
<div class="igBar"><span id="lcsharp-20"><a href="#" onclick="javascript:showCodeTxt('csharp-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-20">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> EventsHelper <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Fire<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Delegate</span> d, <span style="color: #0600FF;">params</span> <span style="color: #FF0000;">object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>d == <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">Delegate</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> dels = d.<span style="color: #0000FF;">GetInvocationList</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Delegate</span> sind <span style="color: #0600FF;">in</span> dels<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">try</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sink.<span style="color: #0000FF;">DynamicInvoke</span><span style="color: #000000;">&#40;</span>args<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span> <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>8. use "property-like" approach for event accessors</strong><br />
As you do with common member variables (expressing them with properties) you also should do this with events. This alows you to control the adding and removing of event handlers for your event.</p>
<div class="igBar"><span id="lcsharp-21"><a href="#" onclick="javascript:showCodeTxt('csharp-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-21">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MyClass <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;MyHandler _myEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">event</span> MyHandler MyEvent <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; add <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_myEvent += value;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; remove <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_myEvent -= value;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>9. Static objects as keys</strong></p>
<div class="igBar"><span id="lcsharp-22"><a href="#" onclick="javascript:showCodeTxt('csharp-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-22">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">static</span> name = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myCollection<span style="color: #000000;">&#91;</span>name<span style="color: #000000;">&#93;</span> = <span style="color: #808080;">"a name"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//instead of (old school)</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myCollection<span style="color: #000000;">&#91;</span><span style="color: #808080;">"name"</span><span style="color: #000000;">&#93;</span> = <span style="color: #808080;">"a name"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
a static object is created to act as a key for e.g. collections (because every instance is unique - has its own identity!). The advantage in comparison to the "old school" version (key is a string) is that the key is already available in memory wheras the string needs to be created everytime. If you use this key in a lot of places it could save some time.</p>
<p><strong>10. Combine enumeration values</strong></p>
<div class="igBar"><span id="lcsharp-23"><a href="#" onclick="javascript:showCodeTxt('csharp-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-23">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">enum</span> color <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;red,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;green,</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;all = red | green</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This example illustrates that it is possible to have enumeration values which accept more than one existing values of the current enumeration.</p>
<p><strong>11. Singelton Application</strong><br />
A singelton application is one which only allows running one instance per machine. e.g. Microsoft Outlook is a singelton application. Everytime the user starts the application it will check if an instance is already running. If its not running it will launch it otherwise it will focus to the current one. The source for an application which runs only once is available in another post "<a href="http://www.webdevbros.net/2007/11/14/singelton-application-with-c/">Singelton Application with C#</a>"</p>
<p><strong>12. Containment</strong><br />
If it is not possible to derive from a class we use a class to wrap around the class we would like to inherit from. This procedure is also known as "Containment" (I mention it here because the this term is more unknown - usually developers use wrapper)</p>
<p><strong>13. Use Debug.Assert()</strong><br />
The use of Debug.Assert should be used as often as possible. During the development the developer should "assert" things which always should be true. This helps finding bugs easier and its easier for other developers to understand the code.</p>
<div class="igBar"><span id="lcsharp-24"><a href="#" onclick="javascript:showCodeTxt('csharp-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-24">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">int</span> a = <span style="color: #FF0000;color:#800000;">10</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">int</span> b = <span style="color: #FF0000;color:#800000;">20</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">int</span> c = <span style="color: #FF0000;color:#800000;">20</span> - <span style="color: #FF0000;color:#800000;">10</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Debug.<span style="color: #0000FF;">Assert</span><span style="color: #000000;">&#40;</span>c&gt; <span style="color: #FF0000;color:#800000;">0</span>, <span style="color: #808080;">"i need it bigger than 0. check might be done in the future"</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">10</span> / c<span style="color: #000000;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This short example demonstrates that obviously the developer expects the variable "c" to be greater than 0. Why? Because in the next line he/she uses it for a dvision which would break with c = 0. If this is the case you would get an information seen in line 4. This concept is nice because it makes comments "active".</p>
<p><strong>14. user string instead of String</strong><br />
String is just an alias for string and therefore its nicer to use the original type straight away. The same with int and Int32, etc.</p>
<p><strong>15. Rethrowing exceptions</strong></p>
<div class="igBar"><span id="lcsharp-25"><a href="#" onclick="javascript:showCodeTxt('csharp-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-25">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">try</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> <span style="color: #0600FF;">catch</span><span style="color: #000000;">&#40;</span>Exception e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//some logging,etc...</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">throw</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This piece of code rethrows the exception. The interesting thing here is that you dont need to specify the Exception explicitly. Just the keyword "throw" is enough to rethrow the exception. </p>
<p><strong>15. Code exclusion with attributes and not with #if .. #endif</strong></p>
<div class="igBar"><span id="lcsharp-26"><a href="#" onclick="javascript:showCodeTxt('csharp-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-26">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#91;</span>Conditional<span style="color: #000000;">&#40;</span><span style="color: #808080;">"DEBUG"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">void</span> Foo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
The advantage here is that the code is not reachable anymore if the condition is not met. This means that it will result in compile errors if you reference this method. #if ... #endif does not enforce this constraint. Its also nicer than the hash signs ;) Please check the <a href="http://msdn2.microsoft.com/en-us/library/aa664622(VS.71).aspx">MSDN Reference</a> for more details about the conditional attribute.</p>
<p>Thats was it :) Hope there was something interesting and maybe new for everyone. I dont want to promote the book here but I really recommend it because it contains good content about programming with c# (and especially for component development) and should be read by every C# developer who wants to develop for enterprise.</p>
<p>Maybe you have some interesting tips &#038; tricks which might be useful for others. Please be so nice and comment them... I am interested.</p>
<p>Resources:<br />
[COMP05] .net Components, Juval Löwy, O'Reilly 2005 United States</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/&amp;t=C%23+tips%2C+tricks+and+things+you+should+know&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/&amp;title=C%23+tips%2C+tricks+and+things+you+should+know&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/&amp;title=C%23+tips%2C+tricks+and+things+you+should+know&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=C%23+tips%2C+tricks+and+things+you+should+know;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/11/14/c-tips-tricks-and-things-you-should-know/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>8 Reasons to Stick with ASP 3.0 in 2006 (and 2007)</title>
		<link>http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/</link>
		<comments>http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 08:56:55 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>

		<guid isPermaLink="false">http://fabiankoehler.de/wdb/?p=27</guid>
		<description><![CDATA[Today I was browsing through the microsoft.­public.­inetserver.­asp.­general newsgroup and found a nice article linked within a topic where people are talking about classic ASP and its brother .net. The article outlines 8 reasons to stick with the good old classic ASP ... Unfortunately I cannot really figure out when the article was written but i [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was browsing through the microsoft.­public.­inetserver.­asp.­general newsgroup and found a nice article linked within a topic where people are talking about classic ASP and its brother .net. <a target="_blank" href="http://www.packtpub.com/article/Classic-ASP">The article </a>outlines 8 reasons to stick with the good old classic ASP ... Unfortunately I cannot really figure out when the article was written but i think it must be quite recent because they bring up VS2005 and web 2.0.</p>
<p>As I have done already some projects with .net I love this statement (refers to web-projects):</p>
<blockquote><p><span lang="EN-GB">Sluggish is a word to describe the whole of the .NET development environment. Starting a new project? Go make a cup of coffee. Switching between tabs? 'Go large' with your coffee. Pressing F1 for help? Make your coffee a take-out and go and have a stroll in the park.</span></p></blockquote>
<p><span lang="EN-GB"><a target="_blank" href="http://www.packtpub.com/article/Classic-ASP">http://www.packtpub.com/article/Classic-ASP</a></span></p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/&amp;t=8+Reasons+to+Stick+with+ASP+3.0+in+2006+%28and+2007%29+&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/&amp;title=8+Reasons+to+Stick+with+ASP+3.0+in+2006+%28and+2007%29+&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/&amp;title=8+Reasons+to+Stick+with+ASP+3.0+in+2006+%28and+2007%29+&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=8+Reasons+to+Stick+with+ASP+3.0+in+2006+%28and+2007%29+;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/03/30/8-reasons-to-stick-with-asp-30-in-2006-and-2007/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
