<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mark Gu&#039;s Blog</title>
	<atom:link href="http://markyourfootsteps.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://markyourfootsteps.wordpress.com</link>
	<description>All about software and computers</description>
	<lastBuildDate>Sat, 16 Apr 2011 04:24:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='markyourfootsteps.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mark Gu&#039;s Blog</title>
		<link>http://markyourfootsteps.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://markyourfootsteps.wordpress.com/osd.xml" title="Mark Gu&#039;s Blog" />
	<atom:link rel='hub' href='http://markyourfootsteps.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Back to Basics &#8211; Interface &amp; Inheritance</title>
		<link>http://markyourfootsteps.wordpress.com/2011/04/16/back-to-basics-interface-inheritance/</link>
		<comments>http://markyourfootsteps.wordpress.com/2011/04/16/back-to-basics-interface-inheritance/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 04:16:15 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.NET FX 4]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://markyourfootsteps.wordpress.com/?p=199</guid>
		<description><![CDATA[Interface and inheritance are the two most basic OO programming concepts, and I believe every developer must be familiar with them; however, that doesn&#8217;t mean every developer will get them right every time. Let&#8217;s start by looking at a basic scenario: public interface IAnimal { void Eat(); } public class Animal : IAnimal { public [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=199&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Interface and inheritance are the two most basic OO programming concepts, and I believe every developer must be familiar with them; however, that doesn&#8217;t mean every developer will get them right every time.</p>
<p>Let&#8217;s start by looking at a basic scenario:</p>
<pre class="brush: csharp;">
public interface IAnimal
{
   void Eat();
}

public class Animal : IAnimal
{
   public virtual void Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat&quot;);
   }
}

public class Mammal : Animal
{
   public override void Eat()
   {
      Concsole.WriteLine(&quot;Mammal Eat&quot;);
   }
}
</pre>
<p>When I execute the following code, the output (in the comments) should not be of a surprise.</p>
<pre class="brush: csharp;">
var m = new Mammal();

m.Eat();                            //Output: Mammal Eat
((Animal)m).Eat();                  //Output: Mammal Eat
((IAnimal)m).Eat();                 //Output: Mammal Eat
</pre>
<p>So if I now change the <code>Animal</code> class to the following, what do you think the outputs will be?</p>
<pre class="brush: csharp;">
public class Animal : IAnimal
{
   public virtual void Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat Implicit&quot;);
   }

   void IAnimal.Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat Explicit&quot;);
   }
}
</pre>
<p>If your thoughts are the same as the below, you are correct.</p>
<pre class="brush: csharp;">
m.Eat();                            //Output: Mammal Eat
((Animal)m).Eat();                  //Output: Mammal Eat
((IAnimal)m).Eat();                 //Output: &lt;strong&gt;Animal Eat Explicit&lt;/strong&gt;
</pre>
<p>Obviously, there is an inconsistency here. When you cast the object explicitly to the interface, the explicit interface implementations will take precedence over the implicit ones. But usually, when you have both implicit and explicit implementations in one class, you&#8217;d have the explicit implementations calling your implicit ones, resulting in the consistent outcome.</p>
<p>Let&#8217;s make another change to the <code>Animal</code> and <code>Mammal</code> class:</p>
<pre class="brush: csharp;">
public class Animal : IAnimal
{
   public void Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat&quot;);
   }
}

public class Mammal : Animal
{
   public new void Eat()
   {
      Concsole.WriteLine(&quot;Mammal Eat&quot;);
   }
}
</pre>
<p>I always feel uncomfortable hiding a base class&#8217;s methods, as seen from the following outputs, the inconsistency introduced is even worse and hard to detect most of the time.</p>
<pre class="brush: csharp;">
m.Eat();                            //Output: Mammal Eat
((Animal)m).Eat();                  //Output: &lt;strong&gt;Animal Eat&lt;/strong&gt;
((IAnimal)m).Eat();                 //Output: &lt;strong&gt;Animal Eat&lt;/strong&gt;
Feed(m);                            //Output: &lt;strong&gt;Animal Eat&lt;/strong&gt;

void Feed(IAnimal a)
{
   a.Eat();
}
</pre>
<p>Clearly, we&#8217;d like to avoid the above situation as much as possible, but sometimes you don&#8217;t have many alternatives, for example, you don&#8217;t have control over the base class.</p>
<p>What you can do to improve this situation is to re-implement the <code>IAnimal</code> interface on <code>Mammal</code>, which gives you slightly more consistent outputs:</p>
<pre class="brush: csharp;">
public class Mammal : Animal, &lt;strong&gt;IAnimal&lt;/strong&gt;
{
   public new void Eat()
   {
      Concsole.WriteLine(&quot;Mammal Eat&quot;);
   }
}

m.Eat();                            //Output: Mammal Eat
((Animal)m).Eat();                  //Output: &lt;strong&gt;Animal Eat&lt;/strong&gt;
((IAnimal)m).Eat();                 //Output: Mammal Eat
Feed(m);                            //Output: Mammal Eat

void Feed(IAnimal a)
{
   a.Eat();
}
</pre>
<p>In summary, if you have control over both base and sub classes, use the following patterns to achieve the most consistent result:</p>
<pre class="brush: csharp;">
public class Animal : IAnimal
{
   public virtual void Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat&quot;);
   }

   void IAnimal.Eat()
   {
      Eat();
   }
}

public class Mammal : Animal
{
   public override void Eat()
   {
      Concsole.WriteLine(&quot;Mammal Eat&quot;);
   }
}
</pre>
<p>or, for some reasons, you really don&#8217;t want to make methods <code>virtual</code>, then try this:</p>
<pre class="brush: csharp;">
public class Animal : IAnimal
{
   public void Eat()
   {
      ((IAnimal)this).Eat();
   }

   void IAnimal.Eat()
   {
      Concsole.WriteLine(&quot;Animal Eat&quot;);
   }
}

public class Mammal : Animal, IAnimal
{
   public new void Eat()
   {
      Concsole.WriteLine(&quot;Mammal Eat&quot;);
   }
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=199&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2011/04/16/back-to-basics-interface-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>Working with Spatial Data (Part 2: Data Formats)</title>
		<link>http://markyourfootsteps.wordpress.com/2011/01/07/working-with-spatial-data-part-2-data-formats/</link>
		<comments>http://markyourfootsteps.wordpress.com/2011/01/07/working-with-spatial-data-part-2-data-formats/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:38:40 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Geospatial]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[WKB]]></category>
		<category><![CDATA[WKT]]></category>

		<guid isPermaLink="false">http://markyourfootsteps.wordpress.com/?p=181</guid>
		<description><![CDATA[This post describes various formats, including both text and binary, which are used to represent spatial objects in database or in file. Well-Known Text (WKT) The WKT format is described in detail in OpenGIS Implementation Specification for Geographic Information – Simple Feature Access Part 1: Common Architecture. Well-Known Binary (WKB) The WKB format is also [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=181&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post describes various formats, including both text and binary, which are used to represent spatial objects in database or in file.</p>
<h1>Well-Known Text (WKT)</h1>
<p>The WKT format is described in detail in <a href="http://www.opengeospatial.org/standards/sfa">OpenGIS Implementation Specification for Geographic Information – Simple Feature Access Part 1: Common Architecture</a>.</p>
<h1>Well-Known Binary (WKB)</h1>
<p>The WKB format is also described in the above linked document. However, I think it&#8217;s helpful to include a diagram and some examples.</p>
<p style="text-align:center;"><a href="http://markyourfootsteps.files.wordpress.com/2010/12/wkb1.png"><img class="aligncenter size-full wp-image-183" title="WKB" src="http://markyourfootsteps.files.wordpress.com/2010/12/wkb1.png?w=630&#038;h=278" alt="" width="630" height="278" /></a></p>
<h3>Examples</h3>
<p><code>Point (1 2)</code> could be represented as:</p>
<p><code>0x<span style="color:#ff6600;">01</span> <span style="color:#99cc00;">01000000</span> <span style="color:#00ccff;">000000000000F03F 0000000000000040</span></code></p>
<p><code>MultiPolygon (((1 1, 1 2, 2 2, 2 1, 1 1)), ((3 1, 4 2, 5 1, 3 1)))</code> could be represented as:</p>
<p><code>0x<span style="color:#ff6600;">01</span> <span style="color:#99cc00;">06000000 </span><span style="color:#ffcc00;">02000000 </span>(<span style="color:#ff6600;">01</span> <span style="color:#99cc00;">03000000 </span><span style="color:#ffcc00;">01000000 </span>(<span style="color:#ffcc00;">05000000 </span>(<span style="color:#00ccff;">000000000000F03F 000000000000F03F 000000000000F03F 0000000000000040 0000000000000040 0000000000000040 0000000000000040 000000000000F03F 000000000000F03F 000000000000F03F</span>)) (<span style="color:#ff6600;">01 </span><span style="color:#99cc00;">03000000 </span><span style="color:#ffcc00;">01000000 </span>(<span style="color:#ffcc00;">04000000 </span>(<span style="color:#00ccff;">0000000000000840 000000000000F03F 0000000000001040 0000000000000040 0000000000001440 000000000000F03F 0000000000000840 000000000000F03F</span>))</code></p>
<p><strong>Note</strong> Spaces and parentheses are added for clarity. They are not part of the binary stream.</p>
<h1>SQL Server Geometry &amp; Geography</h1>
<p>SQL Server 2008 uses its own binary encoding method to encode geometry and geography data.</p>
<p>Unfortunately, I haven&#8217;t managed to find any documentation describing how to decode such format fully.</p>
<h3>Examples</h3>
<p><code>Point (1 2)</code> is represented as:</p>
<p><code>0x00000000010C 000000000000F03F 0000000000000040</code></p>
<p><code>MultiPolygon (((1 1, 1 2, 2 2, 2 1, 1 1)), ((3 1, 4 2, 5 1, 3 1)))</code> is represented as:</p>
<p><code>0x000000000104 09000000 000000000000F03F 000000000000F03F 000000000000F03F 0000000000000040 0000000000000040 0000000000000040 0000000000000040 000000000000F03F 000000000000F03F 000000000000F03F 0000000000000840 000000000000F03F 0000000000001040 0000000000000040 0000000000001440 000000000000F03F 0000000000000840 000000000000F03F 020000000200000000020500000003000000FFFFFFFF0000000006000000000000000003000000000100000003</code></p>
<h1>PostgreSQL &amp; PostGIS</h1>
<p>PostgreSQL uses its own binary format to encode geometry and geography data.</p>
<p>Unfortunately, I haven&#8217;t managed to find any documentation describing how to decode such format fully.</p>
<h1>MySQL</h1>
<p>MySQL uses its own binary format to encode geometry data.</p>
<p>Unfortunately, I haven&#8217;t managed to find any documentation describing how to decode such format fully.</p>
<h1>SQLite &amp; SpatiaLite</h1>
<p>SpatiaLite uses its own binary format to encode geometry data. However, the format is very similar to WKB. Compared with WKB, this format explicitly exposes MBRs, which allows quick access to entities selected on a spatial basis, and partially balances the lacking of spatial indices. For more information, see <a href="http://www.gaia-gis.it/spatialite-2.1/SpatiaLite-manual.html">SpatiaLite - spatial extensions for SQLite</a>.</p>
<p style="text-align:center;"><a href="http://markyourfootsteps.files.wordpress.com/2011/01/sqlite.png"><img class="aligncenter size-full wp-image-190" title="SQLite &amp; SpatiaLite Spatial Data Format" src="http://markyourfootsteps.files.wordpress.com/2011/01/sqlite.png?w=630&#038;h=342" alt="" width="630" height="342" /></a></p>
<h1>SDEBINARY</h1>
<p>SDEBINARY is a compressed binary format used by <a href="http://www.esri.com/software/arcgis/index.html" target="_blank">ArcGIS </a>to store geometry. It offers efficient storage and retrieval of spatial data by reducing the size of the geometry. The representation of SDEBINARY is described in <a href="http://edndoc.esri.com/arcsde/9.1/general_topics/binary_geometry_format.htm">here</a>, and highlighted below:</p>
<p><a href="http://markyourfootsteps.files.wordpress.com/2010/12/sdebinary1.png"><img class="aligncenter size-full wp-image-186" title="SDEBINARY Format" src="http://markyourfootsteps.files.wordpress.com/2010/12/sdebinary1.png?w=630&#038;h=559" alt="ArcSDE Compressed Binary" width="630" height="559" /></a></p>
<h1>Shapefile</h1>
<p><a href="http://en.wikipedia.org/wiki/Shapefile">Shapefile</a> is a popular geospatial vector data format. It is developed and regulated by <a href="http://www.esri.com/">Esri</a> as an open specification for data<br />
interoperability among Esri and other software products.</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tbody>
<tr>
<td width="12%" valign="top"><strong>Bytes</strong></td>
<td width="9%" valign="top"><strong>Type</strong></td>
<td width="13%" valign="top"><strong>Endianness</strong></td>
<td width="68%" valign="top"><strong>Usage</strong></td>
</tr>
<tr>
<td width="12%" valign="top">0–3</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">big</td>
<td width="68%" valign="top">File code (always hex value 0x0000270a)</td>
</tr>
<tr>
<td width="12%" valign="top">4–23</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">big</td>
<td width="68%" valign="top">Unused; five uint32</td>
</tr>
<tr>
<td width="12%" valign="top">24–27</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">big</td>
<td width="68%" valign="top">File length (in 16-bit words, including the header)</td>
</tr>
<tr>
<td width="12%" valign="top">28–31</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">Version</td>
</tr>
<tr>
<td width="12%" valign="top">32–35</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">Shape type (see reference below)</td>
</tr>
<tr>
<td width="12%" valign="top">36–67</td>
<td width="9%" valign="top">double</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">MBR of all shapes contained within the shapefile; four doubles in the<br />
following order: min X, min Y, max X, max Y</td>
</tr>
<tr>
<td width="12%" valign="top">68–83</td>
<td width="9%" valign="top">double</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">Range of Z; two doubles in the following order: min<br />
Z, max Z</td>
</tr>
<tr>
<td width="12%" valign="top">84–99</td>
<td width="9%" valign="top">double</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">Range of M; two doubles in the following order: min M, max M</td>
</tr>
</tbody>
</table>
<p>The file then contains any number of variable-length records. Each record is prefixed with a record-header of 8 bytes:</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tbody>
<tr>
<td width="12%" valign="top"><strong>Bytes</strong></td>
<td width="9%" valign="top"><strong>Type</strong></td>
<td width="13%" valign="top"><strong>Endianness</strong></td>
<td width="68%" valign="top"><strong>Usage</strong></td>
</tr>
<tr>
<td width="12%" valign="top">0–3</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">big</td>
<td width="68%" valign="top">Record number (1-based)</td>
</tr>
<tr>
<td width="12%" valign="top">4–7</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">big</td>
<td width="68%" valign="top">Record length (in 16-bit words)</td>
</tr>
</tbody>
</table>
<p>Following the record header is the actual record:</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tbody>
<tr>
<td width="12%" valign="top"><strong>Bytes</strong></td>
<td width="9%" valign="top"><strong>Type</strong></td>
<td width="13%" valign="top"><strong>Endianness</strong></td>
<td width="68%" valign="top"><strong>Usage</strong></td>
</tr>
<tr>
<td width="12%" valign="top">0–3</td>
<td width="9%" valign="top">int32</td>
<td width="13%" valign="top">little</td>
<td width="68%" valign="top">Shape type (see reference below)</td>
</tr>
<tr>
<td width="12%" valign="top">4–</td>
<td width="9%" valign="top">-</td>
<td width="13%" valign="top">-</td>
<td width="68%" valign="top">Shape content</td>
</tr>
</tbody>
</table>
<p>The variable length record contents depend on the shape type. The following are the possible shape types:</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tbody>
<tr>
<td width="7%" valign="top"><strong>Value</strong></td>
<td width="14%" valign="top"><strong>Shape type</strong></td>
<td width="77%" valign="top"><strong>Fields</strong></td>
</tr>
<tr>
<td width="7%" valign="top">0</td>
<td width="14%" valign="top">Null shape</td>
<td width="77%" valign="top">None</td>
</tr>
<tr>
<td width="7%" valign="top">1</td>
<td width="14%" valign="top">Point</td>
<td width="77%" valign="top">X, Y</td>
</tr>
<tr>
<td width="7%" valign="top">3</td>
<td width="14%" valign="top">Polyline</td>
<td width="77%" valign="top">MBR, Number of parts, Number of points, Parts,<br />
Points</td>
</tr>
<tr>
<td width="7%" valign="top">5</td>
<td width="14%" valign="top">Polygon</td>
<td width="77%" valign="top">MBR, Number of parts, Number of points, Parts, Points</td>
</tr>
<tr>
<td width="7%" valign="top">8</td>
<td width="14%" valign="top">MultiPoint</td>
<td width="77%" valign="top">MBR, Number of points, Points</td>
</tr>
<tr>
<td width="7%" valign="top">11</td>
<td width="14%" valign="top">PointZ</td>
<td width="77%" valign="top">X, Y, Z, M</td>
</tr>
<tr>
<td width="7%" valign="top">13</td>
<td width="14%" valign="top">PolylineZ</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of parts, Number of<br />
points, Parts, Points, Z range, Z array<br />
<em>Optional</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">15</td>
<td width="14%" valign="top">PolygonZ</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of parts, Number of points, Parts,<br />
Points, Z range, Z array<br />
<em>Optional</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">18</td>
<td width="14%" valign="top">MultiPointZ</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of points, Points, Z<br />
range, Z array<br />
<em>Optional</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">21</td>
<td width="14%" valign="top">PointM</td>
<td width="77%" valign="top">X, Y, M</td>
</tr>
<tr>
<td width="7%" valign="top">23</td>
<td width="14%" valign="top">PolylineM</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of parts, Number of<br />
points, Parts, Points<br />
<em>Optional</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">25</td>
<td width="14%" valign="top">PolygonM</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of parts, Number of points, Parts,<br />
Points<br />
<em>Optional</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">28</td>
<td width="14%" valign="top">MultiPointM</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of points, Points<br />
<em>Optional Fields</em>: M range, M array</td>
</tr>
<tr>
<td width="7%" valign="top">31</td>
<td width="14%" valign="top">MultiPatch</td>
<td width="77%" valign="top"><em>Mandatory</em>: MBR, Number of parts, Number of points, Parts, Part<br />
types, Points, Z range, Z array<br />
<em>Optional</em>: M range, M array</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=181&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2011/01/07/working-with-spatial-data-part-2-data-formats/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/wkb1.png" medium="image">
			<media:title type="html">WKB</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2011/01/sqlite.png" medium="image">
			<media:title type="html">SQLite &#38; SpatiaLite Spatial Data Format</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/sdebinary1.png" medium="image">
			<media:title type="html">SDEBINARY Format</media:title>
		</media:content>
	</item>
		<item>
		<title>Working with Spatial Data (Part 1)</title>
		<link>http://markyourfootsteps.wordpress.com/2010/12/17/working-with-spatial-data-part-1/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/12/17/working-with-spatial-data-part-1/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 07:09:27 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Geospatial]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://markyourfootsteps.wordpress.com/?p=174</guid>
		<description><![CDATA[Open Geospatial Consortium (OGC) Standards OGC has developed a few very important standards and specifications that should be respected by any system trying to support geospatial data types. OpenGIS Geography Markup Language (GML) Encoding Standard OpenGIS Implementation Specification for Geographic Information – Simple Feature Access Part 1: Common Architecture OpenGIS Implementation Specification for Geographic Information – Simple Feature [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=174&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Open Geospatial Consortium (OGC) Standards</h1>
<p>OGC has developed a few very important standards and specifications that should be respected by any system trying to support geospatial data types.</p>
<ul>
<li><a href="http://www.opengeospatial.org/standards/gml">OpenGIS Geography Markup Language (GML) Encoding Standard</a></li>
<li><a href="http://www.opengeospatial.org/standards/sfa">OpenGIS Implementation Specification for Geographic Information – Simple Feature Access Part 1: Common Architecture</a></li>
<li><a href="http://www.opengeospatial.org/standards/sfs">OpenGIS Implementation Specification for Geographic Information – Simple Feature Access Part 2: SQL Option</a></li>
</ul>
<h1>Spatial Data Support in .NET &amp; SQL Server 2008</h1>
<p>For a .NET application to make use of the spatial types that are available in Microsoft’s SQL Server 2008, you need to either download and install the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&amp;displaylang=en">Microsoft SQL Server System CLR Types</a> or manually deploy the following assemblies into your application’s directory:</p>
<ul>
<li>Microsoft.SqlServer.Types.dll</li>
<li>SqlServerSpatial.dll</li>
</ul>
<p>Microsoft.SqlServer.Types.dll is a .NET assembly and is installed into GAC (C:\Windows\assembly\) if the installer is used.</p>
<p>SqlServerSpatial.dll is a Windows native assembly and is available in three versions: x86, x64, and ia64. If you use the installer, it will be installed to C:\Windows\System32\ (x64 version), and C:\Windows\SysWOW64\ (x86 version). At runtime, the correct version will be selected automatically based on your application’s target platform. However, if you decide to manually deploy this assembly, you need to place the right version in your application’s directory.</p>
<h2>Basic API</h2>
<p>The assembly Microsoft.SqlServer.Types.dll does not offer a variety of concrete spatial types, such as Point, Rectangle, and Polygon; instead, it only exposes <code>SqlGeometry</code> and <code>SqlGeography</code> as two sealed classes for representing all spatial shapes.</p>
<p><code>SqlGeometry</code> is based on the planar model, which is a uniform 2-dimensional plane where you can define geometric data—points, lines, and polygons—using the x- and y-axis. <code>SqlGeography</code> is based on the geodetic model, which represents a round Earth scenario allowing you define geography data on the Earth’s surface using latitude and longitude.</p>
<p>The easiest way to create a geometry (or geography) feature is to use the static methods on <code>SqlGeometry</code> (or <code>SqlGeography</code>): <code>GeomFromGml()</code>, <code>ST*FromText()</code>, and <code>ST*FromWKB()</code>. These methods are based on the standards: GML (Geographic Markup Language), WKT (Well-Known Text) and WKB (Well-Known Binary) respectively.</p>
<h3>Builder</h3>
<p>For each model mentioned above, Microsoft.SqlServer.Types also exposes a builder class: <code>SqlGeometryBuilder</code> and <code>SqlGeographyBuilder</code> respectively, for creating various kinds of spatial shapes. The following example shows how to create a line from Point (1, 1) to Point (5, 5):</p>
<pre class="brush: csharp;">
SqlGeometryBuilder builder = new SqlGeometryBuilder();
builder.SetSrid(0);
builder.BeginGeometry(OpenGisGeometryType.LineString);
builder.BeginFigure(1, 1);
builder.AddLine(5, 5);
builder.EndFigure();
builder.EndGeometry();

var lineA = builder.ConstructedGeometry;
</pre>
<p>When building a spatial feature, the following methods must be called in the specified order:</p>
<ol>
<li><code>SetSrid(...)</code></li>
<li><code>BeginGeometry(...)</code> / <code>BeginGeography(...)</code></li>
<li><code>BeginFigure(...)</code></li>
<li>&#8230;</li>
<li><code>EndFigure()</code></li>
<li><code>EndGeometry()</code> / <code>EndGeography()</code></li>
</ol>
<p>Depending on the <code>OpenGisGeometryType</code> (or <code>OpenGisGeographyType</code>) value you specified when you first call <code>BeginGeometry</code> (or <code>BeginGeography</code>), you may need to call the methods from Step 2 through to Step 6 multiple times to construct a valid spatial feature. For example, the following code constructs a MultiLineString:</p>
<pre class="brush: csharp;">
var builder = new SqlGeometryBuilder();
builder.SetSrid(0);
builder.BeginGeometry(OpenGisGeometryType.MultiLineString);

builder.BeginGeometry(OpenGisGeometryType.LineString);
builder.BeginFigure(1, 1);
builder.AddLine(5, 5);
builder.EndFigure();
builder.EndGeometry();

builder.BeginGeometry(OpenGisGeometryType.LineString);
builder.BeginFigure(1, 5);
builder.AddLine(5, 1);
builder.EndFigure();
builder.EndGeometry();

builder.EndGeometry();

var multiLineString = builder.ConstructedGeometry;
</pre>
<p><strong>Note</strong> Don’t forget to call the last <code>EndGeometry</code> (or <code>EndGeography</code>). <code>Begin*</code> and <code>End*</code> always go in pairs.</p>
<p>Once a spatial feature is successfully constructed and returned via the property <code>ConstructedGeometry</code> (or <code>ConstructuedGeography</code>), you cannot reuse the same builder instance to build other spatial features, i.e. you can no longer invoke any of the above methods; otherwise, a <code>FormatException</code> will be thrown.</p>
<h3>Spatial Operations</h3>
<p>Once spatial features are created, you can use them to perform spatial operations, such as calculating areas and testing for intersections. For example, the following code prints <code>True</code> indicating <code>lineA</code> and <code>lineB</code> intersect:</p>
<p><strong>Note</strong> When performing spatial operations involving multiple spatial features, their SRIDs must be the same. Otherwise, the operations will return <code>NULL</code>.</p>
<h3>Serialization</h3>
<p>Since both <code>SqlGeometry</code> and <code>SqlGeography</code> are marked as <code>Serializable</code>, their instances can be serialized for communication across networks.</p>
<h3>More Information</h3>
<p>Please refer to the book <a href="http://www.amazon.com/gp/product/1430218290" target="_blank">Beginning Spatial with SQL Server 2008</a> for more information.</p>
<h2>Wrapping the Basic API</h2>
<p>Although the types exposed by Microsoft.SqlServer.Types are sufficient for creating and manipulating spatial features, they form a very loose API and rely heavily on runtime checks. In addition, the basic API exposes SQL data types instead of .NET primitive types, e.g. <code>SqlBoolean</code> versus <code>bool</code>, which makes the coding experience a little awkward. Therefore, it would be beneficial to create a suite of wrapper classes to enable strong type checking and operation IntelliSense based on spatial feature types; for example, calling <code>STCentroid()</code> on a point does not make any sense.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=174&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/12/17/working-with-spatial-data-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>Software Development Books Recommendation (Part 1 of N)</title>
		<link>http://markyourfootsteps.wordpress.com/2010/12/16/software-development-books-recommendation-part-1-of-n/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/12/16/software-development-books-recommendation-part-1-of-n/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 23:59:04 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Parallel Programming]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/2010/12/16/software-development-books-recommendation-part-1-of-n/</guid>
		<description><![CDATA[No blogging for two months. You might be thinking I’ve been lazy, but I tell you what, there was seriously nothing to blog about: the work I have been doing was completely boring and repetitive, and for goodness sake, I haven’t done any serious programming for weeks! It’s slowly killing me! So to prevent from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=168&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>No blogging for two months. You might be thinking I’ve been lazy, but I tell you what, there was seriously nothing to blog about: the work I have been doing was completely boring and repetitive, and for goodness sake, I haven’t done any serious programming for weeks! It’s slowly killing me! So to prevent from getting brain dead, I read a few .NET programming books, some of which are really good and worth promoting.</p>
<p>Compared with reading a blog or search through a forum, reading a good book is still the best way to learn something. Books provide structured content that helps you learning things in a more systematic manner and understanding the ins and outs of a problem.</p>
<p>Okay, enough said, here is the list of books I have read (not word by word of course, and not all chapters are worth reading):</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/Inside-Microsoft-Build-Engine-PRO-Developer/dp/0735626286" target="_blank"><img style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build" src="http://markyourfootsteps.files.wordpress.com/2010/12/image.png?w=155&#038;h=195" border="0" alt="image" width="155" height="195" align="right" /></a>Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build</span></h1>
<p>It’s an outstanding book on MSBuild and Team Foundation Build. Regardless of your experience with these topics, you will find something useful in this book.</p>
<p>I also see this book as a must have for all .NET developers whether or not you are responsible for build automation.</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/gp/product/1590596528" target="_blank"><img class="alignright" style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Deploying .NET Applications: Learning MSBuild and ClickOnce" src="http://markyourfootsteps.files.wordpress.com/2010/12/image1.png?w=155&#038;h=195" border="0" alt="image" width="155" height="195" align="right" /></a>Deploying .NET Applications: Learning MSBuild and ClickOnce</span></h1>
<p>Another great book on MSBuild.</p>
<p>It also includes information on ClickOnce deployment.</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/gp/product/1430229675"><img class="alignright" style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Pro .NET 4 Parallel Programming in C#" src="http://markyourfootsteps.files.wordpress.com/2010/12/image2.png?w=155&#038;h=188" border="0" alt="image" width="155" height="188" align="right" /></a>Pro .NET 4 Parallel Programming in C#</span></h1>
<p>t’s a great book that covers both the old and new ways of doing parallel programming in .NET 4, including topics such as TPL, concurrent collections, synchronization primitives, task schedulers, testing and debugging parallel applications, and some common parallel algorithms.</p>
<p>Another must read for all .NET developers, as like it or not, you cannot escape from parallel programming nowadays.</p>
<p>&#160;</p>
<p>&#160;</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/gp/product/0321440064" target="_blank"><img class="alignright" style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Essential Windows Communication Foundation for .NET Framework 3.5" src="http://markyourfootsteps.files.wordpress.com/2010/12/image3.png?w=155&#038;h=196" border="0" alt="image" width="155" height="196" align="right" /></a>Essential Windows Communication Foundation for .NET Framework 3.5</span></h1>
<p>Although a little out-dated, it is still relevant and has very good explanation on the basics of WCF, especially in the first 10 chapters. However, it is a little light on the security and extensibility topics.</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/gp/product/0470563141" target="_blank"><img class="alignright" style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Professional WCF 4 - Windows Communication Foundation with .NET 4" src="http://markyourfootsteps.files.wordpress.com/2010/12/image4.png?w=155&#038;h=195" border="0" alt="image" width="155" height="195" align="right" /></a>Professional WCF 4 &#8211; Windows Communication Foundation with .NET 4</span></h1>
<p>WCF security is covered extensively in this book—with three chapters ranging from the basic security concepts to advanced federation authentication scenarios.</p>
<p>This book also includes a chapter describing the Windows Azure platform, which is an added bonus.</p>
<p>Again, the drawback of this book is the lack of coverage on WCF extensibility.</p>
<p>&#160;</p>
<p>&#160;</p>
<h1><span style="font-size:medium;"><a href="http://www.amazon.com/gp/product/0672330245"><img style="border:0;padding-top:0;padding-right:0;padding-left:0;display:inline;background-image:none;" title="Windows Communication Foundation 3.5 Unleashed" src="http://markyourfootsteps.files.wordpress.com/2010/12/image5.png?w=155&#038;h=196" border="0" alt="image" width="155" height="196" align="right" /></a>Windows Communication Foundation 3.5 Unleashed</span></h1>
<p>Finally, a book provides extensive coverage on extending and customizing WCF! Topics on other aspects of WCF are quite good also.</p>
<p>I hope it can be updated soon to include things in WCF 4.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=168&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/12/16/software-development-books-recommendation-part-1-of-n/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image.png" medium="image">
			<media:title type="html">Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image1.png" medium="image">
			<media:title type="html">Deploying .NET Applications: Learning MSBuild and ClickOnce</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image2.png" medium="image">
			<media:title type="html">Pro .NET 4 Parallel Programming in C#</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image3.png" medium="image">
			<media:title type="html">Essential Windows Communication Foundation for .NET Framework 3.5</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image4.png" medium="image">
			<media:title type="html">Professional WCF 4 - Windows Communication Foundation with .NET 4</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/12/image5.png" medium="image">
			<media:title type="html">Windows Communication Foundation 3.5 Unleashed</media:title>
		</media:content>
	</item>
		<item>
		<title>Escape Sequences in C#</title>
		<link>http://markyourfootsteps.wordpress.com/2010/10/19/escape-sequences-in-csharp/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/10/19/escape-sequences-in-csharp/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 03:39:30 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[Escape Sequence]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/?p=146</guid>
		<description><![CDATA[&#8220;Escape sequences huh&#8230; everyone knows that: \n, \r, \t, \\ to name a few.&#8221; Well, if you truly think you know all about escape sequences, here are a few challenges for you. Challenge 1: List all the character escape sequences This may not be as easy as you think. If you can come up with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=146&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;Escape sequences huh&#8230; everyone knows that: \n, \r, \t, \\ to name a few.&#8221; Well, if you truly think you know all about escape sequences, here are a few challenges for you.</p>
<h1>Challenge 1: List all the character escape sequences</h1>
<p>This may not be as easy as you think. If you can come up with the following list without consulting the language spec, congratulations!</p>
<p><strong>Solution:</strong></p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td width="98" valign="top"><strong>Escape Sequence</strong></td>
<td width="309" valign="top"><strong>Escaped Character</strong></td>
</tr>
<tr>
<td width="98" valign="top"><code>\’</code></td>
<td width="309" valign="top">single quote</td>
</tr>
<tr>
<td width="98" valign="top"><code>\”</code></td>
<td width="309" valign="top">double quote</td>
</tr>
<tr>
<td width="98" valign="top"><code>\\</code></td>
<td width="309" valign="top">backslash</td>
</tr>
<tr>
<td width="98" valign="top"><code>\a</code></td>
<td width="309" valign="top">alert</td>
</tr>
<tr>
<td width="98" valign="top"><code>\b</code></td>
<td width="309" valign="top">backspace</td>
</tr>
<tr>
<td width="98" valign="top"><code>\f</code></td>
<td width="309" valign="top">form feed</td>
</tr>
<tr>
<td width="98" valign="top"><code>\n</code></td>
<td width="309" valign="top">new line</td>
</tr>
<tr>
<td width="98" valign="top"><code>\r</code></td>
<td width="309" valign="top">carriage return</td>
</tr>
<tr>
<td width="98" valign="top"><code>\t</code></td>
<td width="309" valign="top">horizontal tab</td>
</tr>
<tr>
<td width="98" valign="top"><code>\v</code></td>
<td width="309" valign="top">vertical tab</td>
</tr>
<tr>
<td width="98" valign="top"></td>
<td width="309" valign="top">Unicode character 0 (zero), or null character</td>
</tr>
<tr>
<td width="98" valign="top"><code>\uNNNN</code></td>
<td width="309" valign="top">Unicode character</td>
</tr>
<tr>
<td width="98" valign="top"><code>\UNNNNNNNN</code></td>
<td width="309" valign="top">Unicode character (for generating surrogates)</td>
</tr>
<tr>
<td width="98" valign="top"><code>\xN</code></td>
<td width="309" valign="top">Unicode character (variable length version of <code>\uNNNN</code>)</td>
</tr>
<tr>
<td width="98" valign="top"><code>\xNN</code></td>
<td width="309" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top"><code>\xNNN</code></td>
<td width="309" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top"><code>\xNNNN</code></td>
<td width="309" valign="top"></td>
</tr>
</tbody>
</table>
<p>A few things to note:</p>
<ul>
<li>Each <code>N</code> represents a valid hex digit, i.e. <code>[0-9a-fA-F]</code></li>
<li><code>\x</code> can consume up to 4 characters. For example, if you want to print the Unicode <code>\xFF</code> followed by two &#8220;<code>F</code>&#8221; characters, do NOT write as <code>"\xFFFF"</code>, which means the Unicode character <code>\xFFFF</code>; instead, write <code>"\x00FFFF"</code> or <code>"\xFF" + "FF"</code></li>
<li><code>\UNNNNNNNN</code> is used for generating a pair of surrogates (a high and a low surrogate). Since .NET only supports high surrogate ranging from U+D800 to U+DBFF, and low surrogate ranging from U+DC00 to U+DFFF, the maximum you can specify using <code>\U</code> is <code>\U0010FFFF</code>. Any number larger than that results in a compile error.</li>
<li><code>\UNNNNNNNN</code> occupies two characters, so the string length is one character longer than you&#8217;d expect. Of course, you cannot assign it to a <code>char</code>.</li>
<li>Unlike C/C++ or Java, C# does NOT support  octal escapes.</li>
</ul>
<h1>Challenge 2: Convert an escaped character to its escape sequence</h1>
<p>When you write <code>Console.WriteLine("Title:\r\n\tHello World!")</code>, it prints out:</p>
<p><a href="http://markyourfootsteps.files.wordpress.com/2010/10/image.png"><img class="wlDisabledImage" style="display:inline;border-width:0;" title="image" src="http://markyourfootsteps.files.wordpress.com/2010/10/image_thumb.png?w=137&#038;h=37" border="0" alt="image" width="137" height="37" /></a></p>
<p>The challenge is to write code so that the program outputs <code>"Title:\r\n\tHello World!"</code> in the console at runtime, i.e.</p>
<p><a href="http://markyourfootsteps.files.wordpress.com/2010/10/image1.png"><img class="wlDisabledImage" style="display:inline;border-width:0;" title="image" src="http://markyourfootsteps.files.wordpress.com/2010/10/image_thumb1.png?w=166&#038;h=19" border="0" alt="image" width="166" height="19" /></a></p>
<p><strong>Solution:</strong></p>
<p>The most obvious way is to use <code>string.Replace()</code>, e.g. <code>string.Replace("\r", @"\r")</code>.</p>
<pre class="brush: csharp;">
public static string Escape(string input)
{
    string result = input;

    result = result.Replace(&quot;\\&quot;, @&quot;\\&quot;);    // This needs to be done first!
    result = result.Replace(&quot;\&quot;&quot;, @&quot;\&quot;&quot;&quot;);
    result = result.Replace(&quot;\a&quot;, @&quot;\a&quot;);
    result = result.Replace(&quot;\b&quot;, @&quot;\b&quot;);
    result = result.Replace(&quot;\f&quot;, @&quot;\f&quot;);
    result = result.Replace(&quot;\n&quot;, @&quot;\n&quot;);
    result = result.Replace(&quot;\r&quot;, @&quot;\r&quot;);
    result = result.Replace(&quot;\t&quot;, @&quot;\t&quot;);
    result = result.Replace(&quot;\v&quot;, @&quot;\v&quot;);
    result = result.Replace(&quot;&#092;&#048;&quot;, @&quot;&#092;&#048;&quot;);

    return result;
}
</pre>
<p>Or, if you prefer regular expression, here is another way with slightly more code:</p>
<pre class="brush: csharp;">
public static class StringExtensions
{
    private static Dictionary _escapeMapping = new Dictionary()
    {
        {&quot;\\\\&quot;, @&quot;\\&quot;},
        {&quot;\&quot;&quot;, @&quot;\&quot;&quot;&quot;},
        {&quot;\a&quot;, @&quot;\a&quot;},
        {&quot;\b&quot;, @&quot;\b&quot;},
        {&quot;\f&quot;, @&quot;\f&quot;},
        {&quot;\n&quot;, @&quot;\n&quot;},
        {&quot;\r&quot;, @&quot;\r&quot;},
        {&quot;\t&quot;, @&quot;\t&quot;},
        {&quot;\v&quot;, @&quot;\v&quot;},
        {&quot;&#092;&#048;&quot;, @&quot;&#092;&#048;&quot;},
    };

    private static Regex escapeRegex = new Regex(string.Join(&quot;|&quot;, _escapeMapping.Keys.ToArray()));

    public static string Escape(this string input)
    {
        return escapeRegex.Replace(input, EscapeMatchEval);
    }

    private static string EscapeMatchEval(Match match)
    {
        if (_escapeMapping.ContainsKey(match.Value))
        {
            return _escapeMapping[match.Value];
        }
        return _escapeMapping[Regex.Escape(match.Value)];
    }
}
</pre>
<p>There is also the third way: by using CodeDom and letting .NET handle those replacements for us.</p>
<pre class="brush: csharp;">
public static string Escape(string input)
{
    using (var writer = new StringWriter())
    {
        using (var provider = new Microsoft.CSharp.CSharpCodeProvider())
        {
            provider.GenerateCodeFromExpression(new System.CodeDom.CodePrimitiveExpression(input), writer, null);
        }

        return writer.ToString();
    }
}
</pre>
<p>Although the third way seems pretty cool, it has a few catches. Since CodeDom is really meant for generating code, its engine does a few optimizations; for example, breaking up a long string into multiple shorter ones that are joined by the string concatenation operator, i.e. <code>+</code> in C#. Also, if you try to use <code>Microsoft.VisualBasic.VBCodeProvider</code> instead of the CSharp one, you will end up with outputting <code> Global.Microsoft.VisualBasic.ChrW(13)</code> for <code>\r</code> for example. Finally, due to the limitation in CodeDom, the third way cannot deal with the escape sequences: <code>\a</code>, <code>\b</code>, <code>\f</code>, and <code>\v</code>.</p>
<p>At this point, you may notice that none of the three methods deals with Unicode. But you can easily extend them or create a separate one to deal with escaping Unicode characters. See below as an example:</p>
<pre class="brush: csharp;">
public static string EscapeUnicode(string input)
{
    var builder = new StringBuilder();
    for (int i = 0; i &lt; input.Length; i++)
    {
        if (char.IsSurrogatePair(input, i))
        {
            builder.Append(&quot;\\U&quot; + char.ConvertToUtf32(input, i).ToString(&quot;X8&quot;));
            i++;  //skip the next char
        }
        else
        {
            int charVal = char.ConvertToUtf32(input, i);
            if (charVal &gt; 127)
            {
                builder.Append(&quot;\\u&quot; + charVal.ToString(&quot;X4&quot;));
            }
            else
            {
                //an ASCII character
                builder.Append(input[i]);
            }
        }
    }

    return builder.ToString();
}
</pre>
<h1>Challenge 3: Convert an escape sequence to the escaped character</h1>
<p>It’s the reverse of the challenge 2, and it’s a lot more interesting! &#8230;well, only so if you can come up with more than one way.</p>
<p>Let&#8217;s say if you are reading a file that contains escape sequences, when the content is read into a string, escape sequences are treated as individual characters and are escaped in memory, e.g. <code>\n</code> in file becomes <code>\\n</code> in memory. Now what you need to do is to convert <code>\\n</code> back to <code>\n</code> in memory at runtime to represent a new line character.</p>
<p><strong>Solution:</strong></p>
<p>You may still resort to <code>string.Replace()</code> and regular expressions (needed to handle Unicode), but there is a much better and more elegant way doing it.</p>
<pre class="brush: csharp;">
public static string ParseString(string input)
{
    var provider = new Microsoft.CSharp.CSharpCodeProvider();
    var parameters = new System.CodeDom.Compiler.CompilerParameters()
    {
        GenerateExecutable = false,
        GenerateInMemory = true,
    };

    var code = @&quot;
        namespace Tmp
        {
            public class TmpClass
            {
                public static string GetValue()
                {
                    return &quot;&quot;&quot; + input + @&quot;&quot;&quot;;
                }
            }
        }&quot;;

    var compileResult = provider.CompileAssemblyFromSource(parameters, code);

    if (compileResult.Errors.HasErrors)
    {
        throw new ArgumentException(compileResult.Errors.Cast&lt;System.CodeDom.Compiler.CompilerError&gt;().First(e =&gt; !e.IsWarning).ErrorText);
    }

    var asmb = compileResult.CompiledAssembly;
    var method = asmb.GetType(&quot;Tmp.TmpClass&quot;).GetMethod(&quot;GetValue&quot;);

    return method.Invoke(null, null) as string;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=146&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/10/19/escape-sequences-in-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/10/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://markyourfootsteps.files.wordpress.com/2010/10/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>The Essentials of Writing High Quality JavaScript</title>
		<link>http://markyourfootsteps.wordpress.com/2010/10/18/the-essentials-of-writing-high-quality-javascript/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/10/18/the-essentials-of-writing-high-quality-javascript/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 22:23:10 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://markyourfootsteps.wordpress.com/?p=137</guid>
		<description><![CDATA[Although I&#8217;m not doing much web &#38; JavaScript programming, I still like to reference the article The Essentials of Writing High Quality JavaScript, which is an excerpt of the book JavaScript Patterns by Stoyan Stefanov. &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=137&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Although I&#8217;m not doing much web &amp; JavaScript programming, I still like to reference the article <a href="http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/">The Essentials of Writing High Quality JavaScript</a>, which is an excerpt of the book <a href="http://www.amazon.com/gp/product/0596806752?ie=UTF8&amp;tag=nett02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596806752" target="_blank">JavaScript Patterns</a> by Stoyan Stefanov.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=137&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/10/18/the-essentials-of-writing-high-quality-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>Loading Assemblies &#8211; A Quick Reminder</title>
		<link>http://markyourfootsteps.wordpress.com/2010/10/08/loading-assemblies-a-quick-reminder/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/10/08/loading-assemblies-a-quick-reminder/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 01:28:04 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[AppDomain]]></category>
		<category><![CDATA[Assembly]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/?p=132</guid>
		<description><![CDATA[Every once a while, I need to dig my head into the .NET Reflection and try to pull some crazy tricks out for the framework I’m developing. As part of that, I need to load and analyze assemblies from all over the place. Since .NET offers a few ways to load an assembly, and different [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=132&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Every once a while, I need to dig my head into the .NET Reflection and try to pull some crazy tricks out for the framework I’m developing. As part of that, I need to load and analyze assemblies from all over the place.</p>
<p>Since .NET offers a few ways to load an assembly, and different ways result in different outcomes, it’s always a little bit confusing after some time not working in that domain. The good thing is, there are plenty of helpful materials on the Internet, especially the following articles, so I decided to put them all in one place for future reference.</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/1009fa28.aspx" target="_blank">Assembly.LoadFrom (MSDN)</a></li>
<li><a href="http://blogs.msdn.com/b/suzcook/archive/2003/09/19/loadfile-vs-loadfrom.aspx" target="_blank">LoadFile vs. LoadFrom (Suzanne Cook’s .NET CLR Notes)</a></li>
<li><a href="http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57143.aspx" target="_blank">Choosing a Binding Context (Suzanne Cook’s .NET CLR Notes)</a></li>
</ul>
<p>Other notes:</p>
<ul>
<li>To manually load an assembly from GAC, you have to specify the FULL name of the assembly.</li>
<li>You can’t selectively unload one or more assemblies from a AppDomain, you have to unload the whole AppDomain instead. Therefore, if you don’t want to pollute your main AppDomain with the assemblies you want to unload at a later stage, create a new one. I wrote the following code to do that:</li>
</ul>
<p>First, create a class called <code>AssemblyAnalyzerGateway</code>. This class requires a type argument, and optionally takes an AppDomain object as its constructor parameter. The type argument specifies the type of the analyzer to create in the specified AppDomain (or a new AppDomain if nothing is specified), and the analyzer will be the one driving the actual assembly analysis.</p>
<p>Note that for objects to be accessible from outside their living AppDomains, they have to be either serializable or inherited from <code>MarshalByRefObject</code>. Here I constrain it to be <code>MarshalByRefObject</code> only, so there is no de/serialization happening.</p>
<p>Note also that <code>AssemblyAnalyzerGateway</code> implements <code>IDisposable</code>, so when it&#8217;s disposed, it unloads the AppDomain even when the AppDomain is not created by the analyzer.</p>
<pre class="brush: csharp;">
public class AssemblyAnalyzerGateway&lt;T&gt; : IDisposable
    where T : MarshalByRefObject
{
    public AssemblyAnalyzerGateway()
        : this(null)
    {
    }

    public AssemblyAnalyzerGateway(AppDomain workDomain)
    {
        if (workDomain == null)
        {
            workDomain = AppDomain.CreateDomain(&quot;Assembly Analysis Domain&quot;);
        }

        this.WorkDomain = workDomain;

        var analyzerType = typeof(T);
        this.Analyzer = workDomain.CreateInstanceFromAndUnwrap(analyzerType.Assembly.Location,
            analyzerType.FullName, true,
            BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance,
            null, null, System.Globalization.CultureInfo.CurrentCulture, null) as T;
    }

    public AppDomain WorkDomain { get; private set; }

    public T Analyzer { get; private set; }

    #region IDisposable Members

    private bool _disposed;

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    private void Dispose(bool disposing)
    {
        if (!_disposed)
        {
            AppDomain.Unload(WorkDomain);
        }

        _disposed = true;
    }

    #endregion
}
</pre>
<p>Now, let&#8217;s move to the analyzer that does the actual assembly analysis. There are a few things to note here:</p>
<ol>
<li>as mentioned before, the analyzer needs to be inherited from MarshalByRefObject;</li>
<li>it must have a parameterless constructor, which doesn&#8217;t have to be public though;</li>
<li>all of its exposed methods should be instance methods, NOT static. However, if you think some of these methods could be used elsewhere, feel free to redirect the calls. Since the analyzer is created in a separate AppDomain, any objects or types it references will be created in that domain as well.</li>
</ol>
<pre class="brush: csharp;">
public class AssemblyAnalyzer : MarshalByRefObject
{
    private AssemblyAnalyzer() { }

    public void AnalyzeAssembly(string asmbPath)
    {
        Assembly asmb = LoadAssemblyAt(asmbPath);
        ...
    }
}
</pre>
<p>Finally, to use the above code:</p>
<pre class="brush: csharp;">
using (var gateway = new AssemblyAnalyzerGateway&lt;AssemblyAnalyzer&gt;())
{
    return gateway.Analyzer.AnalyzeAssembly(asmbPath);
}
</pre>
<p>or if you don&#8217;t want throw away the AppDomain immediately, but keep it for other analysis:</p>
<pre class="brush: csharp;">
AppDomain.CurrentDomain.AssemblyResolve += AppDomain_AssemblyResolve;
AppDomain workDomain = AppDomain.CreateDomain(&quot;Assembly Analysis Domain&quot;);

var analyzer = new AssemblyAnalyzerGateway&lt;AssemblyAnalyzer&gt;(workDomain);
var anotherAnalyzer = new AssemblyAnalyzerGateway&lt;MyOtherAssemblyAnalyzer&gt;(workDomain);

try
{
    ...
}
finally
{
    AppDomain.Unload(workDomain);
    AppDomain.CurrentDomain.AssemblyResolve -= AppDomain_AssemblyResolve;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=132&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/10/08/loading-assemblies-a-quick-reminder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>Need a decent syntax highlighter plug-in</title>
		<link>http://markyourfootsteps.wordpress.com/2010/10/08/need-a-decent-syntax-highlighter-plug-in/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/10/08/need-a-decent-syntax-highlighter-plug-in/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 23:35:23 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[News & Opinions]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Syntax Highlighter]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/2010/10/08/need-a-decent-syntax-highlighter-plug-in/</guid>
		<description><![CDATA[It’s been a pain trying to put some code snippets on WordPress using Windows Live Writer. I have tried a few plug-ins, and none of them does a decent job, either the UI is a total disaster, or the generated HTML doesn’t get along with the theme and surrounding paragraphs, and… don’t even get me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=131&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It’s been a pain trying to put some code snippets on WordPress using Windows Live Writer. I have tried a few plug-ins, and none of them does a decent job, either the UI is a total disaster, or the generated HTML doesn’t get along with the theme and surrounding paragraphs, and… don’t even get me started on the syntax coloring and formatting/displaying options that are available.</p>
<p>Which makes me wondering: what’s so difficult about writing a good syntax highlighter—hundreds of notepad like applications do it. Is this about the compatibility between WL Writer and WordPress, or else? (… knowing that the Windows Live team has officially killed Spaces and tries to move everyone to WordPress)</p>
<p>The good thing is that WordPress does provide a nice syntax highlighting mechanism, by using the tag [/sourcecode], which is developed my <a href="http://alexgorbatchev.com/SyntaxHighlighter/" target="_blank">Alex Gorbatchev</a>. This tool supports a good range of languages, and does a great job formatting and displaying code snippets. However, it doesn’t provide design time (WYSIWYG) support, and you can’t seem to use it inside WL Writer, as the writer ignores the tag and escapes all the characters, especially after a post is downloaded and opened for editing inside the writer.</p>
<p>Furthermore, writing and editing blog posts on the WordPress website isn’t a good experience either, especially when you’re trying to edit HTML directly—the cursor jumps up and down causing a lot of frustrations. Finally when you trying to post the blog with code snippets, 80% chances are that you lose leading spaces and indentations in your code…</p>
<p>Why WordPress and/or WL Writer cannot provide a decent syntax highlighter?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=131&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/10/08/need-a-decent-syntax-highlighter-plug-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>CodeDom needs update!</title>
		<link>http://markyourfootsteps.wordpress.com/2010/09/15/codedom-needs-update/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/09/15/codedom-needs-update/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 04:40:13 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[CodeDom]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/2010/09/15/codedom-needs-update/</guid>
		<description><![CDATA[Recently, I’ve been working on code generations using CodeDom, which gives me quite a few frustrations. Most of them come from the fact that some language features are not supported by CodeDom. I can understand that CodeDom is a little old (came with .NET FX 2.0), and is slow on catching up fast evolving language [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=109&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I’ve been working on code generations using CodeDom, which gives me quite a few frustrations. Most of them come from the fact that some language features are not supported by CodeDom.</p>
<p>I can understand that CodeDom is a little old (came with .NET FX 2.0), and is slow on catching up fast evolving language features, such as LINQ, lambda expressions, and XML literals (VB 9+), but it’s still a great mechanism to generate language independent code, and should be kept up-to-date as much as possible.</p>
<p>In the following, I’d like to summarize some of the language features that aren&#8217;t supported by CodeDom, together with the suggested workarounds. Note that CodeDom should only cover the concepts and features exposed by most languages (at least .NET languages). Since I have limited experience with Visual C++ and F#, I’ll only include the features that are present in both C# and VB.NET.</p>
<p><strong>Note:</strong> LINQ, lambda expressions, extension methods are not included in the following list.</p>
<h2>Partial method</h2>
<p>Partial method is a new feature that comes with .NET FX 3.5, so there is no support for it in CodeDom.</p>
<pre class="brush: csharp; light: true;">
new CodeSnippetTypeMember(string.Format(&quot;{0}{0}partial void Initialize();&quot;, IndentText))
</pre>
<pre class="brush: vb; light: true;">
new CodeSnippetTypeMember(string.Format(&quot;{0}{0}Partial Private Sub Initialize()&quot; + Environment.NewLine + &quot;{0}{0}End Sub&quot;, Indent))
</pre>
<h2>Different accessibility modifiers on the getter and setter of a property</h2>
<p>This feature is quite useful for protect object encapsulation. For example:<br />
C#:</p>
<pre class="brush: csharp; light: true;">
public string Name
{
   get { ... }
   protected set { ... }
}
</pre>
<p>VB.NET:</p>
<pre class="brush: vb; light: true;">
Public Property Name() As String
   Get
      ...
   End Get
   Protected Set(ByVal value As String)
      ...
   End Set
}
</pre>
<p>Same as before, the only way to generate this code is to use code snippet, which is NOT language independent and defeats the purpose of using CodeDom in the first place.</p>
<p>However, a good programmer must not surrender to this, and should still use CodeDom to generate as much language independent code as possible, e.g. property name (to avoid name clashing with keywords), property type (to avoid hard-coding generic type argument syntax), and get and set statements.</p>
<p>The trick is to use the following extension methods to convert CodeDom statements and expressions to text.</p>
<pre class="brush: csharp;">
public static string Serialize(this CodeDomProvider provider, CodeExpression expr)
{
   using (TextWriter writer = new StringWriter())
   {
      provider.GenerateCodeFromExpression(expr, writer, new CodeGeneratorOptions());
      return writer.ToString();
   }
}

public static string Serialize(this CodeDomProvider provider, CodeStatement stmt)
{
   using (TextWriter writer = new StringWriter())
   {
      provider.GenerateCodeFromStatement(stmt, writer, new CodeGeneratorOptions());
      return writer.ToString();
   }
}
</pre>
<p>Then we only need to take care of the keywords, see below:</p>
<pre class="brush: csharp;">
var builder = new StringBuilder();

var propTypeText = _provider.Serialize(new CodeTypeReferenceExpression(propertyType));
var propNameText = _provider.Serialize(new CodeVariableReferenceExpression(name.UppercaseFirstChar()));

var getStmt = new CodeMethodReturnStatement(...);
var setStmt = new CodeMethodInvokeExpression(...);

switch (_outputLanguage)
{
   case OutputLanguage.CSharp:
      builder.Append(&quot;{0}{0}public &quot;).Append(propTypeText).Append(&quot; &quot;).AppendLine(propNameText);
      builder.AppendLine(&quot;{0}{0}{{&quot;);

      builder.AppendLine(&quot;{0}{0}{0}get&quot;);
      builder.AppendLine(&quot;{0}{0}{0}{{&quot;);
      builder.Append(&quot;{0}{0}{0}{0}&quot;).Append(_provider.Serialize(getStmt));
      builder.AppendLine(&quot;{0}{0}{0}}}&quot;);

      builder.AppendLine(&quot;{0}{0}{0}protected set&quot;);
      builder.AppendLine(&quot;{0}{0}{0}{{&quot;);
      builder.Append(&quot;{0}{0}{0}{0}&quot;).Append(_provider.Serialize(setStmt)).AppendLine(&quot;;&quot;);
      builder.AppendLine(&quot;{0}{0}{0}}}&quot;);

      builder.AppendLine(&quot;{0}{0}}}&quot;);
      break;
   case OutputLanguage.VB:
      builder.Append(&quot;{0}{0}Public Property &quot;).Append(propNameText).Append(&quot;() As &quot;).AppendLine(propTypeText);

      builder.AppendLine(&quot;{0}{0}{0}Get&quot;);
      builder.Append(&quot;{0}{0}{0}{0}&quot;).Append(_provider.Serialize(getStmt));
      builder.AppendLine(&quot;{0}{0}{0}End Get&quot;);

      builder.Append(&quot;{0}{0}{0}Protected Set(ByVal value As &quot;).Append(propTypeText).AppendLine(&quot;)&quot;);
      builder.Append(&quot;{0}{0}{0}{0}&quot;).AppendLine(_provider.Serialize(setStmt));
      builder.AppendLine(&quot;{0}{0}{0}End Set&quot;);

      builder.AppendLine(&quot;{0}{0}End Property&quot;);
      break;
}

var property = new CodeSnippetTypeMember(string.Format(builder.ToString(), Indent));
</pre>
<h2>Structure Constraint</h2>
<p>Generate for C#:</p>
<pre class="brush: csharp; light: true;">
var typeParam = new CodeTypeParameter(“T”)
{
   Constraints = { ” struct” }, //Note the SPACE before ‘struct’
};
</pre>
<p>Generate for VB.NET:</p>
<pre class="brush: csharp; light: true;">
var typeParam = new CodeTypeParameter(“T”)
{
   Constraints = { ” Structure” }, //Note the SPACE before ‘Structure’
};
</pre>
<h2>Constants inside a function</h2>
<p>Since <span style="line-height:115%;font-family:consolas;color:#2b91af;font-size:9pt;">MemberAttributes</span><span style="line-height:115%;font-family:consolas;font-size:9pt;">.Const</span> is only supported on <span style="line-height:115%;font-family:consolas;color:#2b91af;font-size:9pt;">CodeTypeMember</span>, you have to use code snippet again in this case. However, a good thing is that the keyword (<span style="line-height:115%;font-family:consolas;color:blue;font-size:9pt;">const</span>) spells the same in C# and VB.NET, so you can use the lower case version for both.</p>
<h2>Block &#8211; using</h2>
<p>Generate <span style="line-height:115%;font-family:consolas;color:blue;font-size:9pt;">try</span><span style="line-height:115%;font-family:consolas;font-size:9pt;"> &#8230; <span style="color:blue;">finally</span> &#8230;</span> instead. For example:</p>
<pre class="brush: csharp; light: true;">
using (TextWriter w = new StringWriter())
{
}
</pre>
<p>can be rewritten as:</p>
<pre class="brush: csharp; light: true;">
TextWriter w = new StringWriter();
try
{
}
finally
{
   w.Dispose();
}
</pre>
<h2>Block &#8211; foreach</h2>
<p>Use enumerator instead. For example:</p>
<pre class="brush: csharp; light: true;">
foreach (var item in myList)
{
}
</pre>
<p>can be rewritten as:</p>
<pre class="brush: csharp; light: true;">
var enumerator = myList.GetEnumerator();
while(enumerator.MoveNext())
{
   var item = enumerator.Current;
}
</pre>
<h2>Block &#8211; lock</h2>
<p>This one took me a little bit time to find a workaround. The trick is to use the Monitor class from the System.Threading namespace, see the following example:</p>
<pre class="brush: csharp; light: true;">
lock (obj)
{
}
</pre>
<p>can be rewritten as:</p>
<pre class="brush: csharp; light: true;">
object copyObj = obj;
System.Threading.Monitor.Enter(copyObj);
try
{
}
finally
{
   System.Threading.Monitor.Exit(copyObj);
}
</pre>
<h2>Ternary operator</h2>
<p>Generate <span style="line-height:115%;font-family:consolas;color:blue;font-size:9pt;">if</span><span style="line-height:115%;font-family:consolas;font-size:9pt;"> &#8230; <span style="color:blue;">else</span> &#8230;</span>  instead.</p>
<p>That’s it for now! I’ll keep extending this post if I find more unsupported features in CodeDom, and their workarounds.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=109&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/09/15/codedom-needs-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
		<item>
		<title>Job Hunting &amp; Interview Tips</title>
		<link>http://markyourfootsteps.wordpress.com/2010/09/01/job-hunting-interview-tips/</link>
		<comments>http://markyourfootsteps.wordpress.com/2010/09/01/job-hunting-interview-tips/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 02:43:10 +0000</pubDate>
		<dc:creator>Mark Gu</dc:creator>
				<category><![CDATA[News & Opinions]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">https://markyourfootsteps.wordpress.com/2010/09/01/job-hunting-interview-tips/</guid>
		<description><![CDATA[Today, I came across this article listing 6 job search tips for software programmers, and I agree with them wholeheartedly. In the past, I have also given advice to friends and people who came to me asking for tips and tricks about job search and interview. Although I’m not a company’s CEO nor HR manager, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=108&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, I came across <a href="http://mashable.com/2010/08/29/job-search-tips-programmers" target="_blank">this article</a> listing 6 job search tips for software programmers, and I agree with them wholeheartedly.</p>
<p>In the past, I have also given advice to friends and people who came to me asking for tips and tricks about job search and interview. Although I’m not a company’s CEO nor HR manager, most of my advice is aligned with what I read on the aforementioned website. The only difference is that my advice was more geared towards university graduates, whose first language isn’t English, but even so, it still applies to the “general” majority. So I think it’s necessary to reiterate those 6 tips and to add some of my personal views:</p>
<h3>Don’t Mess Up Your Resume</h3>
<p>Spelling and grammar errors are your biggest enemy. Replying on tools is simply NOT enough, you should always, always, proofread your resume yourself; or get somebody else to do it for you if he/she speaks better English.</p>
<p>Focus on the first page of your resume. In addition to your personal info, only write down what you think the most important things are—things that make you stand out from the crowd.</p>
<h3>Be Smart and Get Things Done</h3>
<p>Build a personal website, join and be active in professional social networks, e.g. LinkedIn, and online communities, e.g. MSDN forums, Code Project, and Stack Overflow. Nowadays, employers will not only look at your paper resume, but also your footprints on the Internet.</p>
<h3>Check Your Ego</h3>
<p>Don’t be arrogant nor too modest. Find a balance to sell yourself.</p>
<h3>Learn People Language, Too</h3>
<p>Also, learn some psychology and body language. They will help you greatly during interviews.</p>
<h3>Be Prepared to Prove Yourself in the Interview</h3>
<p>Practice, practice and practice. If your English isn’t good enough or you easily become nervous in situations like this, practice in front of a mirror, family members, friends or even neighbors, ask them to throw interview questions at you.</p>
<p>Also, you should prepare answers for commonly asked questions, such as “What do you know about our company?”, “How do other people describe you?”, “Why do you think we should hire you?”, “What are you good at?”, “What are you not good at?”, “What are your short-term (and long-term) plans?”…</p>
<p>Finally, pick up a computer text book to review some basics, such as data structures, algorithms, Boolean logics, basic programming concepts and terminologies. Remember to review the coding standards and good coding habits as well, since more and more employers like to give you some programming quiz to do during interviews.</p>
<h3>Don’t Fake It</h3>
<p>Stick to what you know and what you are good at, and just say “I don’t know” when you don’t know. Never, ever, lie about it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/markyourfootsteps.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/markyourfootsteps.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/markyourfootsteps.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=markyourfootsteps.wordpress.com&amp;blog=11604926&amp;post=108&amp;subd=markyourfootsteps&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://markyourfootsteps.wordpress.com/2010/09/01/job-hunting-interview-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0334a6ddeeb75d554ff18ecef8b398ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mark</media:title>
		</media:content>
	</item>
	</channel>
</rss>
